From cc8718f3f29db7587e070b198693518b03657b4c Mon Sep 17 00:00:00 2001 From: Moz <39520581+moz-ljp@users.noreply.github.com> Date: Tue, 21 May 2019 20:28:33 +0100 Subject: [PATCH 1/4] May fix for linux --- __init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index 4c919609..3efa1773 100644 --- a/__init__.py +++ b/__init__.py @@ -19,11 +19,6 @@ from __future__ import absolute_import, division, print_function -try: - import time -except: - print("Couldn't import time") - try: import platform except: @@ -60,6 +55,8 @@ OS = platform.system() +OS = "Linux" + username = getpass.getuser() if(OS == "Windows"): From f3a00505705ffc55a1c0d83ea56406af227ae669 Mon Sep 17 00:00:00 2001 From: Moz <39520581+moz-ljp@users.noreply.github.com> Date: Tue, 21 May 2019 20:29:07 +0100 Subject: [PATCH 2/4] fix for linux maybe --- __init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/__init__.py b/__init__.py index 3efa1773..419a1d77 100644 --- a/__init__.py +++ b/__init__.py @@ -55,8 +55,6 @@ OS = platform.system() -OS = "Linux" - username = getpass.getuser() if(OS == "Windows"): From 4ede50ad5c6ba2bfc582495f5b31b0df7fe1017c Mon Sep 17 00:00:00 2001 From: Moz <39520581+moz-ljp@users.noreply.github.com> Date: Mon, 23 Sep 2019 20:19:35 +0100 Subject: [PATCH 3/4] Added missing return False for linux os --- __init__.py | 123 +++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 64 deletions(-) diff --git a/__init__.py b/__init__.py index 419a1d77..ae20d1c2 100644 --- a/__init__.py +++ b/__init__.py @@ -19,102 +19,97 @@ from __future__ import absolute_import, division, print_function -try: - import platform -except: - print("Couldn't import platform library") - -import os - -import subprocess +def boot_supercollider(): + """ Uses subprocesses to boot supercollider from the cli """ -try: - import psutil -except: - os.system("pip install psutil") - -try: + import time + import platform + import os + import subprocess import getpass -except: - print("Couldn't import getpass library") + try: + import psutil + except ImportError: + os.system("pip install psutil") + import sys + sys.exit("Installed psutil, please start FoxDot again.") -sclangpath = "" #find path to sclang + sclangpath = "" #find path to sclang -thispath = "" #find this path + thispath = "" #find this path -""" + thisdir = os.getcwd() -Sclang path and supercollider path are the same but need to go to the actual file for sclang + OS = platform.system() -For CWR (current working directory) need to go to the folder that contains sclang (also contains supercollider (scide.exe)) + username = getpass.getuser() -""" + if(OS == "Windows"): -thisdir = os.getcwd() + print("OS: Windows") -OS = platform.system() + sclangloc = os.popen('where /R "C:\\Program Files" sclang.exe').read() -username = getpass.getuser() + thiscwd = str(sclangloc) -if(OS == "Windows"): + ourcwd = thiscwd.replace('\\sclang.exe\n', '') - print("OS: Windows") + def is_proc_running(name): + for p in psutil.process_iter(attrs=["name", "exe", "cmdline"]): + #print(p); + procname = p.info['name'] or \ + p.info['exe'] and os.path.basename(p.info['exe']) == name or \ + p.info['cmdline'] and p.info['cmdline'][0] == name + if(procname.startswith(name)): + return True + return False - sclangloc = os.popen('where /R "C:\Program Files" sclang.exe').read() - thiscwd = str(sclangloc) + running = (is_proc_running("sclang")) - ourcwd = thiscwd.replace('\\sclang.exe\n', '') + if(running == False): + startup = thisdir+"/FoxDot/startup.scd" + #os.system("sclang"+startup+" &") + subprocess.Popen([sclangloc, startup], cwd=ourcwd, shell=True) - def is_proc_running(name): - for p in psutil.process_iter(attrs=["name", "exe", "cmdline"]): - #print(p); - procname = p.info['name'] or \ - p.info['exe'] and os.path.basename(p.info['exe']) == name or \ - p.info['cmdline'] and p.info['cmdline'][0] == name - if(procname.startswith(name)): - return True - return False + elif(OS == "Linux"): + print("OS: Linux") - running = (is_proc_running("sclang")) + def is_proc_running(name): + for p in psutil.process_iter(attrs=["name","cmdline"]): + #print(p); + procname = p.info['name'] or \ + p.info['cmdline'] and p.info['cmdline'][0] == name + if(procname.startswith(name)): + return True + return False - if(running == False): - startup = thisdir+"/FoxDot/startup.scd" - #os.system("sclang"+startup+" &") - subprocess.Popen([sclangloc, startup], cwd=ourcwd, shell=True) -elif(OS == "Linux"): + running = (is_proc_running("sclang")) - print("OS: Linux") + if(running == False): + startup = thisdir+"/FoxDot/startup.scd" + #os.system('sclang "/home/foxdot/Desktop/FoxDot-Cross-Platform/FoxDot/startup.scd" &') #fuctional + os.system("sclang "+startup+" &") - def is_proc_running(name): - for p in psutil.process_iter(attrs=["name","cmdline"]): - #print(p); - procname = p.info['name'] or \ - p.info['cmdline'] and p.info['cmdline'][0] == name - if(procname.startswith(name)): - return True - return False + else: + print("Operating system unrecognised") + #Potentially get the user to choose their OS from a list? + #Then run the corresponding functions - running = (is_proc_running("sclang")) +import sys - if(running == False): - startup = thisdir+"/FoxDot/startup.scd" - #os.system('sclang "/home/foxdot/Desktop/FoxDot-Cross-Platform/FoxDot/startup.scd" &') #fuctional - os.system("sclang "+startup+" &") +if "--boot" in sys.argv: + boot_supercollider() -else: - print("Operating system unrecognised") - #Potentially get the user to choose their OS from a list? - #Then run the corresponding functions + sys.argv.remove("--boot") from .lib import * - def main(): """ Function for starting the GUI when importing the library """ FoxDot = Workspace.workspace(FoxDotCode).run() From 2524e50f896e6aa0e9d428678fe27ac4d9ecd345 Mon Sep 17 00:00:00 2001 From: Moz <39520581+moz-ljp@users.noreply.github.com> Date: Wed, 8 Apr 2020 19:12:57 +0100 Subject: [PATCH 4/4] Changed bootup sequence Currently is_proc_running always returns false as the old method has since been outdated and now not functioning. Using the --boot flag on windows functions well. --- __init__.py | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/__init__.py b/__init__.py index ae20d1c2..de5968fc 100644 --- a/__init__.py +++ b/__init__.py @@ -35,6 +35,22 @@ def boot_supercollider(): import sys sys.exit("Installed psutil, please start FoxDot again.") + """ + def is_proc_running(name): + for p in psutil.process_iter(attrs=["name", "exe", "cmdline"]): + #print(p); + procname = p.info['name'] or \ + p.info['exe'] and os.path.basename(p.info['exe']) == name or \ + p.info['cmdline'] and p.info['cmdline'][0] == name + if(name in str(procname)): + return True + return False + """ + + def is_proc_running(ourcwd): + return False + + sclangpath = "" #find path to sclang thispath = "" #find this path @@ -47,45 +63,26 @@ def boot_supercollider(): if(OS == "Windows"): - print("OS: Windows") - sclangloc = os.popen('where /R "C:\\Program Files" sclang.exe').read() thiscwd = str(sclangloc) ourcwd = thiscwd.replace('\\sclang.exe\n', '') - def is_proc_running(name): - for p in psutil.process_iter(attrs=["name", "exe", "cmdline"]): - #print(p); - procname = p.info['name'] or \ - p.info['exe'] and os.path.basename(p.info['exe']) == name or \ - p.info['cmdline'] and p.info['cmdline'][0] == name - if(procname.startswith(name)): - return True - return False + final = ourcwd + "\sclang.exe" + print(final) - running = (is_proc_running("sclang")) + running = (is_proc_running(final)) if(running == False): + print("Booting supercollider background process...") startup = thisdir+"/FoxDot/startup.scd" #os.system("sclang"+startup+" &") subprocess.Popen([sclangloc, startup], cwd=ourcwd, shell=True) - elif(OS == "Linux"): - - print("OS: Linux") - - def is_proc_running(name): - for p in psutil.process_iter(attrs=["name","cmdline"]): - #print(p); - procname = p.info['name'] or \ - p.info['cmdline'] and p.info['cmdline'][0] == name - if(procname.startswith(name)): - return True - return False + elif(OS == "Linux"): running = (is_proc_running("sclang")) @@ -112,7 +109,7 @@ def is_proc_running(name): def main(): """ Function for starting the GUI when importing the library """ - FoxDot = Workspace.workspace(FoxDotCode).run() + FoxDot = Workspace.Editor.workspace(FoxDotCode).run() def Go(): """ Function to be called at the end of Python files with FoxDot code in to keep