Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pierre's changes to ofProject script to accept examples folder

  • Loading branch information...
commit f0c4d397cd10267bfa6b268cd5a479ecaea9961f 1 parent b4d1f72
@arturoc arturoc authored
Showing with 38 additions and 12 deletions.
  1. +38 −12 scripts/linux/ofProjectManager/ofProjectManager.py
View
50 scripts/linux/ofProjectManager/ofProjectManager.py
@@ -6,27 +6,42 @@
import sys
from ofEnvironment import of_root
+of_path = of_root + "apps/myApps/"
+
class ofProjectManager:
"""class to add addons to projects"""
- def __init__(self,project):
+# def __init__(self,project):
+# try:
+# f = open(of_path + project + "/" + project + ".cbp","r")
+# f.close()
+# except IOError:
+# self.createFromEmpty(project)
+#
+# self.projectName = project
+# self.project = ofProject(of_path + project + "/" + project + ".cbp")
+
+ def __init__(self,project,path=""):
+ global of_path
try:
- f = open(of_root + "apps/myApps/" + project + "/" + project + ".cbp","r")
+ if len(path) != 0:
+ of_path = path
+ f = open(of_path + project + "/" + project + ".cbp","r")
f.close()
except IOError:
self.createFromEmpty(project)
self.projectName = project
- self.project = ofProject(of_root + "apps/myApps/" + project + "/" + project + ".cbp")
+ self.project = ofProject(of_path + project + "/" + project + ".cbp")
def createFromEmpty(self,project):
- shutil.copytree (of_root + "apps/examples/emptyExample",of_root + "apps/myApps/" + project)
- shutil.move(of_root + "apps/myApps/"+project+"/emptyExample.cbp", of_root +"apps/myApps/" + project+ "/" + project + ".cbp")
- f = open(of_root + "apps/myApps/" + project + "/" + project + ".cbp","r")
+ shutil.copytree (of_root + "apps/examples/emptyExample",of_path + project)
+ shutil.move(of_path + project+"/emptyExample.cbp", of_path + project+ "/" + project + ".cbp")
+ f = open(of_path + project + "/" + project + ".cbp","r")
projectStr = f.read()
f.close()
projectStr = projectStr.replace("emptyExample",project)
- f = open(of_root + "apps/myApps/" + project + "/" + project + ".cbp","w")
+ f = open(of_path + project + "/" + project + ".cbp","w")
f.write(projectStr)
def addAddon(self,addon):
@@ -34,7 +49,7 @@ def addAddon(self,addon):
self.project.addAddon(addon)
def saveProject(self):
- f = open(of_root + "apps/myApps/" + self.projectName + "/"+self.projectName+".cbp","w")
+ f = open(of_path + self.projectName + "/"+self.projectName+".cbp","w")
self.project.xml(f);
f.close()
@@ -43,15 +58,26 @@ def saveProject(self):
if __name__ == "__main__":
if(len(sys.argv) > 2):
if sys.argv[1] == "add":
- if(len(sys.argv) > 3):
- projectManager = ofProjectManager(sys.argv[2])
+ if(len(sys.argv) > 4):
+ projectManager = ofProjectManager(sys.argv[2],sys.argv[4])
projectManager.addAddon(sys.argv[3])
projectManager.saveProject()
+ else:
+ if(len(sys.argv) > 3):
+ projectManager = ofProjectManager(sys.argv[2])
+ projectManager.addAddon(sys.argv[3])
+ projectManager.saveProject()
if sys.argv[1] == "create":
- projectManager = ofProjectManager(sys.argv[2])
+ if(len(sys.argv) > 3):
+ # specify project path
+ projectManager = ofProjectManager(sys.argv[2],sys.argv[3])
projectManager.saveProject()
-
+ else:
+ if(len(sys.argv) > 2):
+ # do not specify project path
+ projectManager = ofProjectManager(sys.argv[2])
+ projectManager.saveProject()
else:
print """Usage: ofProjectManager [command] [project] [addon]
commands: create
Please sign in to comment.
Something went wrong with that request. Please try again.