|
1 | | -#!/usr/bin/python |
2 | | - |
3 | | -""" |
4 | | -
|
5 | | -FoxDot is a Python library and programming environment that provides a fast and |
6 | | -user-friendly abstraction to the powerful audio-engine, SuperCollider. It comes |
7 | | -with its own IDE, which means it can be used straight out of the box; all you need |
8 | | -is Python and SuperCollider and you're ready to go! |
9 | | -
|
10 | | -For more information on installation, check out [the guide](http://foxdot.org/installation), |
11 | | -or if you're already set up, you can also find a useful starter guide that introduces the |
12 | | -key components of FoxDot on [the website](http://foxdot.org/). |
13 | | -
|
14 | | -Please see the [documentation](http://docs.foxdot.org/) for more detailed information on |
15 | | -the FoxDot classes and how to implement them. |
16 | | -
|
17 | | -Copyright Ryan Kirkbride 2015 |
18 | | -""" |
19 | | - |
20 | | -from __future__ import absolute_import, division, print_function |
21 | | - |
22 | | -try: |
23 | | - import time |
24 | | -except: |
25 | | - print("Couldn't import time") |
26 | | - |
27 | | -try: |
28 | | - import platform |
29 | | -except: |
30 | | - print("Couldn't import platform library") |
31 | | - |
32 | | -import os |
33 | | - |
34 | | -import subprocess |
35 | | - |
36 | | -try: |
37 | | - import psutil |
38 | | -except: |
39 | | - os.system("pip install psutil") |
40 | | - |
41 | | -try: |
42 | | - import getpass |
43 | | -except: |
44 | | - print("Couldn't import getpass library") |
45 | | - |
46 | | - |
47 | | -sclangpath = "" #find path to sclang |
48 | | - |
49 | | -thispath = "" #find this path |
50 | | - |
51 | | -""" |
52 | | -
|
53 | | -Sclang path and supercollider path are the same but need to go to the actual file for sclang |
54 | | -
|
55 | | -For CWR (current working directory) need to go to the folder that contains sclang (also contains supercollider (scide.exe)) |
56 | | -
|
57 | | -""" |
58 | | - |
59 | | -thisdir = os.getcwd() |
60 | | - |
61 | | -OS = platform.system() |
62 | | - |
63 | | -username = getpass.getuser() |
64 | | - |
65 | | -if(OS == "Windows"): |
66 | | - |
67 | | - print("OS: Windows") |
68 | | - |
69 | | - sclangloc = os.popen('where /R "C:\Program Files" sclang.exe').read() |
70 | | - |
71 | | - thiscwd = str(sclangloc) |
72 | | - |
73 | | - ourcwd = thiscwd.replace('\\sclang.exe\n', '') |
74 | | - |
75 | | - def is_proc_running(name): |
76 | | - for p in psutil.process_iter(attrs=["name", "exe", "cmdline"]): |
77 | | - #print(p); |
78 | | - procname = p.info['name'] or \ |
79 | | - p.info['exe'] and os.path.basename(p.info['exe']) == name or \ |
80 | | - p.info['cmdline'] and p.info['cmdline'][0] == name |
81 | | - if(procname.startswith(name)): |
82 | | - return True |
83 | | - return False |
84 | | - |
85 | | - |
86 | | - running = (is_proc_running("sclang")) |
87 | | - |
88 | | - if(running == False): |
89 | | - startup = thisdir+"/FoxDot/startup.scd" |
90 | | - #os.system("sclang"+startup+" &") |
91 | | - subprocess.Popen([sclangloc, startup], cwd=ourcwd, shell=True) |
92 | | - |
93 | | -elif(OS == "Linux"): |
94 | | - |
95 | | - print("OS: Linux") |
96 | | - |
97 | | - def is_proc_running(name): |
98 | | - for p in psutil.process_iter(attrs=["name","cmdline"]): |
99 | | - #print(p); |
100 | | - procname = p.info['name'] or \ |
101 | | - p.info['cmdline'] and p.info['cmdline'][0] == name |
102 | | - if(procname.startswith(name)): |
103 | | - return True |
104 | | - return False |
105 | | - |
106 | | - |
107 | | - running = (is_proc_running("sclang")) |
108 | | - |
109 | | - if(running == False): |
110 | | - startup = thisdir+"/FoxDot/startup.scd" |
111 | | - #os.system('sclang "/home/foxdot/Desktop/FoxDot-Cross-Platform/FoxDot/startup.scd" &') #fuctional |
112 | | - os.system("sclang "+startup+" &") |
113 | | - |
114 | | - |
115 | | -else: |
116 | | - print("Operating system unrecognised") |
117 | | - #Potentially get the user to choose their OS from a list? |
118 | | - #Then run the corresponding functions |
119 | | - |
120 | | -from .lib import * |
121 | | - |
122 | | - |
123 | | -def main(): |
124 | | - """ Function for starting the GUI when importing the library """ |
125 | | - FoxDot = Workspace.workspace(FoxDotCode).run() |
126 | | - |
127 | | -def Go(): |
128 | | - """ Function to be called at the end of Python files with FoxDot code in to keep |
129 | | - the TempoClock thread alive. """ |
130 | | - try: |
131 | | - import time |
132 | | - while 1: |
133 | | - time.sleep(100) |
134 | | - except KeyboardInterrupt: |
135 | | - return |
0 commit comments