Skip to content

Commit

Permalink
Merge pull request #749 from rzellem/develop
Browse files Browse the repository at this point in the history
v0.46.3: fix alignment bug in GUI
  • Loading branch information
rzellem authored Jun 17, 2021
2 parents b297eef + bb6058f commit c26ca28
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 46 deletions.
42 changes: 42 additions & 0 deletions exotic/animate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import threading
import time
import sys


done_flag_animate_exotic = None
th_animate_exotic = None


def animate():
import itertools
for c in itertools.cycle(['|', '/', '-', '\\']):
if done_flag_animate_exotic:
sys.stdout.write('\rThinking ... DONE!')
sys.stdout.write('\n')
break
sys.stdout.write('\rThinking ' + c + ' ... ')
sys.stdout.flush()
time.sleep(0.11)
sys.stdout.flush()


def animate_toggle(enabled=False):
"""
Console feature intended to be run in a single synchronous block.
"""
global done_flag_animate_exotic
global th_animate_exotic
counter_wait = 0
if enabled:
done_flag_animate_exotic = False
th_animate_exotic = threading.Thread(target=animate, daemon=True)
th_animate_exotic.start()
else:
done_flag_animate_exotic = True
if th_animate_exotic is not None: # kill animate thread before proceeding
while th_animate_exotic.is_alive() and counter_wait <= 30:
time.sleep(.37)
counter_wait += 1
th_animate_exotic.join() # lightest solution
th_animate_exotic = None
return not done_flag_animate_exotic
43 changes: 4 additions & 39 deletions exotic/exotic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,12 @@
# ########################################################################### #
# -- IMPORTS START ------------------------------------------------------------
# ########## IMPORTS -- PRELOAD ANIMATION START ##########
done_flag_animate_exotic = None
th_animate_exotic = None

import threading
import time
import sys


def animate():
import itertools
for c in itertools.cycle(['|', '/', '-', '\\']):
if done_flag_animate_exotic:
sys.stdout.write('\rThinking ... DONE!')
sys.stdout.write('\n')
break
sys.stdout.write('\rThinking ' + c + ' ... ')
sys.stdout.flush()
time.sleep(0.11)
sys.stdout.flush()


def animate_toggle(enabled=False):
"""
Console feature intended to be run in a single synchronous block.
"""
global done_flag_animate_exotic
global th_animate_exotic
counter_wait = 0
if enabled:
done_flag_animate_exotic = False
th_animate_exotic = threading.Thread(target=animate, daemon=True)
th_animate_exotic.start()
else:
done_flag_animate_exotic = True
if th_animate_exotic is not None: # kill animate thread before proceeding
while th_animate_exotic.is_alive() and counter_wait <= 30:
time.sleep(.37)
counter_wait += 1
th_animate_exotic.join() # lightest solution
th_animate_exotic = None
return not done_flag_animate_exotic
try: # animation
from animate import *
except ImportError:
from .animate import *


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion exotic/exotic_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def save_input():
else:
input_data['platesolve'] = 'n'

if platesolve.get():
if alignment.get():
input_data['alignment'] = 'y'
else:
input_data['alignment'] = 'n'
Expand Down
6 changes: 6 additions & 0 deletions exotic/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from util import user_input, dms_to_dd, open_elevation, typecast_check, init_params
except ImportError:
from .util import user_input, dms_to_dd, open_elevation, typecast_check, init_params
try:
from animate import *
except ImportError:
from .animate import *


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -342,7 +346,9 @@ def elevation(elev, lat, long):
if not elev:
log_info("\nEXOTIC is retrieving elevation based on entered "
"latitude and longitude from Open Elevation.")
animate_toggle(True)
elev = open_elevation(lat, long)
animate_toggle()
if not elev:
log_info("\nEXOTIC could not retrieve elevation.")
elev = user_input("Enter the elevation (in meters) of where you observed: ", type_=float)
Expand Down
2 changes: 1 addition & 1 deletion exotic/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.46.2"
__version__ = "0.46.3"
10 changes: 5 additions & 5 deletions run_exotic_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ then
echo -e "ERROR: Incompatible or missing Python runtime. Please install\n" \
" Python 3.6 or above. EXITING!"
echo -e "For more information, see ${py_download}. ...\n"
exit 65
exit 127
fi
# test for pip
for app in ${pip_commands} ; do
Expand All @@ -77,17 +77,17 @@ then
echo "INFO: Installing 'Pip Installs Packages' (pip) for Python3. ..."
echo " DOWNLOADING ..."
# install pip3
if curl &>/dev/null ;
if curl --version &>/dev/null ;
then
curl -O "${pip_download}"
elif wget &>/dev/null ;
elif wget --version &>/dev/null ;
then
wget "${pip_download}"
else
echo -e "ERROR: Unable to download package manager. Please install\n" \
" Pip for Python 3. EXITING!"
echo -e "For more information, see ${pip_instructions}. ...\n"
exit 65
exit 127
fi
${py_runner} get-pip.py
pip_runner="pip3"
Expand All @@ -97,7 +97,7 @@ then
echo -e "ERROR: Incompatible or missing package manager. Please install\n" \
" Pip for Python 3. EXITING!"
echo -e "For more information, see ${pip_instructions}. ...\n"
exit 65
exit 127
fi
fi
# exec commands using determinate pip
Expand Down

0 comments on commit c26ca28

Please sign in to comment.