from storage import *

'''
Class responsible for creating and controlling the creation of activities
'''

class Space:

	'''
	Create an instance of the Storage class
	'''
	def __init__(self):
		self.storage = Storage()


	'''
	Add an space to the JSON

	@returns: nothing
	'''
	def add(self, name):
		space_obj = {"space": name, "sources": []}
		self.storage.addSpace(space_obj)


	'''
	Delete the entire space from the JSON
	'''
	def delete(self, name):
		self.storage.deleteSpace(name)


	'''
	Start the space

	Applications are stored as a string array.
	Bash command 'open' each.

	@returns: nothing
	'''
	def start(self, name):
		space_obj = self.storage.getSpace(name)
		if space_obj == -1:
			print name + ' does not exist.'

		for source in space_obj['sources']:
			os.system('open ' + source)


	
@@ -14,16 +14,34 @@
 import *
+%0Aimport subprocess
 %0A%0A'''%0ACl
@@ -789,34 +789,40 @@
 %0A%09%09%09
-os.system(
+subprocess.call(%5B
 'open
- ' +
+',
  source
+%5D
 )%0A%0A%0A

fix crash with spaces in app name