Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get github automation working on ubuntu #903

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions castervoice/lib/github_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from castervoice.lib.utilities import load_toml_file
from castervoice.lib import settings


def _copy_path():
if not os.path.isfile(settings.SETTINGS["paths"]["GIT_REPO_LOCAL_REMOTE_PATH"]):
git_match_default = settings.SETTINGS["paths"]["GIT_REPO_LOCAL_REMOTE_DEFAULT_PATH"]
Expand Down Expand Up @@ -49,16 +48,16 @@ def github_checkoutupdate_pull_request(new):
TERMINAL_PATH = settings.SETTINGS["paths"]["TERMINAL_PATH"]
AHK_PATH = settings.SETTINGS["paths"]["AHK_PATH"]
ahk_installed = os.path.isfile(AHK_PATH)
print("AHK_PATH = " + AHK_PATH)
if TERMINAL_PATH != "":
load_terminal = True # set default value
# ready fetch command string to be appended to
fetch_command = ""
# find the equivalent ahk script with the same name as this one
ahk_script = __file__.replace(".pyc", ".ahk").replace(".py", ".ahk")
pattern_match = "MINGW64" # the string we expect to find in the title of git bash when loaded

# if autohotkey is installed
if ahk_installed:
pattern_match = "MINGW64" # the string we expect to find in the title of git bash when loaded
# open the script which checks that git bash window is open or not
p = Popen([AHK_PATH, ahk_script, "exists", pattern_match], stdout=PIPE)
# retrieve the output from the ahk script
Expand All @@ -81,7 +80,10 @@ def github_checkoutupdate_pull_request(new):
print("Fallback: load new instance of :" + pattern_match)
if load_terminal:
# open up a new git bash terminal
terminal = Popen(TERMINAL_PATH, cwd=local_directory)
if os.path.isfile(TERMINAL_PATH):
terminal = Popen(TERMINAL_PATH, cwd=local_directory)
else:
raise Exception("Error: terminal path not set correctly in settings.toml")
# if autohotkey is installed
if ahk_installed:
# open the script which checks that git bash windoow is ready or not for input
Expand Down
20 changes: 16 additions & 4 deletions castervoice/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,25 @@ def _deep_merge_defaults(data, defaults):


def _get_defaults():
terminal_path_default = "C:/Program Files/Git/git-bash.exe"

if sys.platform == "win32":
terminal_path_default = "C:/Program Files/Git/git-bash.exe"
elif sys.platform.startswith("linux"):
terminal_path_default = "/usr/bin/gnome-terminal"
elif sys.platform == "darwin":
terminal_path_default = "/Applications/Utilities/Terminal.app"

if not os.path.isfile(terminal_path_default):
terminal_path_default = ""

ahk_path_default = "C:/Program Files/AutoHotkey/AutoHotkey.exe"
LexiconCode marked this conversation as resolved.
Show resolved Hide resolved
if not os.path.isfile(ahk_path_default):
ahk_path_default = ""


if sys.platform == "win32":
terminal_loading_time = 5
else:
terminal_loading_time = 1
return {
"paths": {
"BASE_PATH":
Expand Down Expand Up @@ -301,7 +312,7 @@ def _get_defaults():

# EXECUTABLES
"AHK_PATH":
str(Path(_BASE_PATH).joinpath(ahk_path_default)),
str(Path(ahk_path_default)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I'm not so sure of. I don't think that this was ever right

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as ahk_path_default should already include the base path

"DOUGLAS_PATH":
str(Path(_BASE_PATH).joinpath("asynch/mouse/grids.py")),
"ENGINE_PATH":
Expand Down Expand Up @@ -365,8 +376,9 @@ def _get_defaults():
},

# gitbash settings
# This really should be labelled "terminal" but was named when caster was Windows only.
"gitbash": {
"loading_time": 5, # the time to initialise the git bash window in seconds
"loading_time": terminal_loading_time, # the time to initialise the git bash window in seconds
"fetching_time": 3 # the time to fetch a github repository in seconds
},

Expand Down