def decompressNewProject(self, rq): print "decompress" f = rq['data'] name = f['name'] contents = f['data'] storageUnit = rq['storageUnit'] +"/" #print contents # get configuration from file confFile = weioConfig.getConfiguration() pathCurrentProject = "www/" + storageUnit projectName = name.split(".tar")[0] data = {} if (weioFiles.checkIfDirectoryExists(pathCurrentProject+projectName) is False) : #decode from base64, file is binary bb = contents bb = bb.split(",")[1] # split header, for example: "data:image/jpeg;base64," weioFiles.saveRawContentToFile(pathCurrentProject+name, bb.decode("base64")) #print "save to ", pathCurrentProject+name weioFiles.createDirectory(pathCurrentProject+projectName) #print "mkdir ", pathCurrentProject+"userProjects/"+projectName weioFiles.unTarFile(pathCurrentProject+name, pathCurrentProject+projectName) #print "untar ", pathCurrentProject+"userProjects/"+projectName data['request'] = "changeProject" data['data'] = storageUnit+projectName self.changeProject(data) else : data['requested'] = 'status' data['status'] = "Error this projet already exists" self.broadcast(clients, json.dumps(data))
def newProject(self, rq): config = weioConfig.getConfiguration() print "NEW PROJECT", rq data = {} data['requested'] = rq['request'] path = "" storage = rq['storageUnit'] path = "www/" + rq['storageUnit'] + "/" + rq['path'] print "CREATE PROJECT", path if (len(path)>0): if (weioFiles.checkIfDirectoryExists(path)): print "ALREADY EXISTS" data['status'] = "Can't create project" data['error'] = "already exists" data['path'] = path self.broadcast(clients, json.dumps(data)) else : weioFiles.createDirectory(path) # ADD HERE SOME DEFAULT FILES # adding __init__.py weioFiles.saveRawContentToFile(path + "/__init__.py", "") # make symlink to www/ if (storage == "sd" or storage == "usbFlash"): if (storage == "sd"): if os.path.isdir(path): if not (os.path.exists(path + "/www")): print "COPYING TO ", path + "/www" copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns('sd', 'flash', 'examples', 'usbFlash')) print "OK" else: if not (os.path.exists(path + "/www")): print "COPYING TO ", path + "/www" copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns('sd', 'flash', 'examples', 'usbFlash')) print "OK" else: try: os.remove(path + "/www") except: print "Symlink don't exist. Will create new one for this project" os.symlink(config["absolut_root_path"] + "/www/", path + "/www") # copy all files from directory boilerplate to destination mypath = "www/libs/weio/boilerPlate/" onlyfiles = [ f for f in os.listdir(mypath) if isfile(join(mypath,f)) ] for f in onlyfiles: copyfile(mypath+f, path +"/"+f) print "LASTOPENED new project", path config["last_opened_project"] = path weioConfig.saveConfiguration(config); data['status'] = "New project created" data['path'] = path self.broadcast(clients, json.dumps(data)) else: print "BAD PATHNAME"
def newProject(self, rq): config = weioConfig.getConfiguration() print "NEW PROJECT", rq data = {} data['requested'] = rq['request'] path = "" storage = rq['storageUnit'] path = "www/" + rq['storageUnit'] + "/" + rq['path'] print "CREATE PROJECT", path if (len(path)>0): weioFiles.createDirectory(path) # ADD HERE SOME DEFAULT FILES # adding __init__.py weioFiles.saveRawContentToFile(path + "/__init__.py", "") # make symlink to www/ try : os.remove(path + "/www") except: print "Symlink don't exist. Will create new one for this project" os.symlink(config["absolut_root_path"] + "/www/", path + "/www") # copy all files from directory boilerplate to destination mypath = "www/libs/weio/boilerPlate/" onlyfiles = [ f for f in os.listdir(mypath) if isfile(join(mypath,f)) ] for f in onlyfiles: copyfile(mypath+f, path +"/"+f) print "LASTOPENED new project", path config["last_opened_project"] = path weioConfig.saveConfiguration(config); data['status'] = "New project created" data['path'] = path self.broadcast(clients, json.dumps(data)) else: print "BAD PATHNAME"
def newProject(self, rq): config = weioConfig.getConfiguration() print "NEW PROJECT", rq data = {} data['requested'] = rq['request'] path = "" storage = rq['storageUnit'] path = "www/" + rq['storageUnit'] + "/" + rq['path'] print "CREATE PROJECT", path if (len(path) > 0): if (weioFiles.checkIfDirectoryExists(path)): print "ALREADY EXISTS" data['status'] = "Can't create project" data['error'] = "already exists" data['path'] = path self.broadcast(clients, json.dumps(data)) else: weioFiles.createDirectory(path) # ADD HERE SOME DEFAULT FILES # adding __init__.py weioFiles.saveRawContentToFile(path + "/__init__.py", "") # make symlink to www/ if (storage == "sd" or storage == "usbFlash"): if (storage == "sd"): if os.path.isdir(path): if not (os.path.exists(path + "/www")): print "COPYING TO ", path + "/www" copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns( 'sd', 'flash', 'examples', 'usbFlash')) print "OK" else: if not (os.path.exists(path + "/www")): print "COPYING TO ", path + "/www" copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns( 'sd', 'flash', 'examples', 'usbFlash')) print "OK" else: try: os.remove(path + "/www") except: print "Symlink don't exist. Will create new one for this project" os.symlink(config["absolut_root_path"] + "/www/", path + "/www") # copy all files from directory boilerplate to destination mypath = "www/libs/weio/boilerPlate/" onlyfiles = [ f for f in os.listdir(mypath) if isfile(join(mypath, f)) ] for f in onlyfiles: copyfile(mypath + f, path + "/" + f) print "LASTOPENED new project", path config["last_opened_project"] = path weioConfig.saveConfiguration(config) data['status'] = "New project created" data['path'] = path self.broadcast(clients, json.dumps(data)) else: print "BAD PATHNAME"