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

Hopefully fixed boot_supercollider (FoxDot --boot) for linux distros #210

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
127 changes: 57 additions & 70 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,110 +19,97 @@

from __future__ import absolute_import, division, print_function

try:
import time
except:
print("Couldn't import time")
def boot_supercollider():
""" Uses subprocesses to boot supercollider from the cli """

try:
import time
import platform
except:
print("Couldn't import platform library")

import os

import subprocess

try:
import psutil
except:
os.system("pip install psutil")

try:
import os
import subprocess
import getpass
except:
print("Couldn't import getpass library")


sclangpath = "" #find path to sclang
try:
import psutil
except ImportError:
os.system("pip install psutil")
import sys
sys.exit("Installed psutil, please start FoxDot again.")

thispath = "" #find this path
"""
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

Sclang path and supercollider path are the same but need to go to the actual file for sclang

sclangpath = "" #find path to sclang

For CWR (current working directory) need to go to the folder that contains sclang (also contains supercollider (scide.exe))
thispath = "" #find this path

"""
thisdir = os.getcwd()

thisdir = os.getcwd()
OS = platform.system()

OS = platform.system()
username = getpass.getuser()

username = getpass.getuser()
if(OS == "Windows"):

if(OS == "Windows"):
sclangloc = os.popen('where /R "C:\\Program Files" sclang.exe').read()

print("OS: Windows")
thiscwd = str(sclangloc)

sclangloc = os.popen('where /R "C:\Program Files" sclang.exe').read()
ourcwd = thiscwd.replace('\\sclang.exe\n', '')

thiscwd = str(sclangloc)
final = ourcwd + "\sclang.exe"

ourcwd = thiscwd.replace('\\sclang.exe\n', '')
print(final)

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
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)

running = (is_proc_running("sclang"))

if(running == False):
startup = thisdir+"/FoxDot/startup.scd"
#os.system("sclang"+startup+" &")
subprocess.Popen([sclangloc, startup], cwd=ourcwd, shell=True)
elif(OS == "Linux"):

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()
FoxDot = Workspace.Editor.workspace(FoxDotCode).run()

def Go():
""" Function to be called at the end of Python files with FoxDot code in to keep
Expand Down