def rename_survey(old_name, new_name): try: os.rename("web/User/Surveys/" + old_name, "web/User/Surveys/" + new_name) eel.update_master_surveys(old_name, new_name) except Exception as err: print(err) eel.python_bootbox(str(err))
def new_user(username): # check if users folder exists if os.path.isdir("web/Users") == False: os.mkdir("web/Users") #check if the user already exists if os.path.exists("web/Users/" + username): eel.python_bootbox("User: <b>" + username + "</b> user already exists") else: os.mkdir("web/Users/" + username) eel.new_user_added(username) eel.python_bootbox("User: <b>" + username + "</b> created")
def push_collector(username, password, organisation, repository, this_message): print("trying to push to the repository") if organisation == "": organisation = username #create repository if that fails #os.system("git push https://github.com/open-collector/open-collector") try: print(this_message) os.system("git add .") os.system('git commit -m "' + str(this_message) + '"') os.system("git push https://" + username + ":" + password + "@github.com/" + organisation + "/" + repository+ ".git") print("It all seems to have worked - mostly speaking") except: print("looks like I need to create a repository to push to") eel.python_bootbox("Creating repositories from Collector not yet implemented - please create the repository on github"); ''' #need to make this a repository if(organisation != username): create_repository = organisation + "/" + repository else : create_repository = repository os.system('git init') # check if hub is installed # this may require installing scoop for windows # or brew for mac/linux os.system('eval "$(ssh-agent -s)"') os.system("hub create " + create_repository) os.system("git add .") os.system("git commit -m 'pushing from local'") os.system("git push https://" + username + ":" + password + "@github.com/" + organisation + "/" + repository+ ".git") #git config receive.denyCurrentBranch refuse #git push --set-upstream py2rm-collector #os.system("git push https://" + username + ":" + password + "@github.com/" + organisation + "/" + repository) ''' finally: print("It all seems to have worked - mostly speaking")
def save_experiment(experiment_name,experiment_json): errors = "" print("trying to save experiment") if os.path.isdir("web/User/Experiments") == False: os.mkdir("web/User/Experiments") print(experiment_name) print(json.dumps(experiment_json)) experiment_file = open("web/User/Experiments/" + experiment_name + ".json", "w") experiment_file.write(json.dumps(experiment_json)) python_message = "Experiment saved" eel.python_bootbox(python_message) if os.path.isdir("web/User/Experiments/" + experiment_name) == False: os.mkdir("web/User/Experiments/" + experiment_name) python_message = python_message + "...<br> saving <b>conditions.csv</b>" eel.python_bootbox(python_message) try: this_cond_file = open("web/User/Experiments/" + experiment_name + "/conditions.csv", "w", newline='') this_cond_file.write(experiment_json["python_conditions"]) except: errors += "...<br><span class='text-danger'>Error when trying to save <b>conditions.csv</b> - is the file open on your computer?</span>" eel.python_bootbox(python_message) finally: print("moving on") for this_proc in experiment_json["python_procs"].keys(): python_message = python_message + "...<br> saving the procedure <b>" + this_proc + "</b>" eel.python_bootbox(python_message) print(this_proc) try: this_proc_file = open("web/User/Experiments/" + experiment_name + "/" + this_proc, "w", newline='') this_proc_file.write(experiment_json["python_procs"][this_proc]) except: errors += "...<br><span class='text-danger'>Error when trying to save <b>" + \ this_proc + \ "</b> - is the file open on your computer?</span>" eel.python_bootbox(python_message) finally: print("moving on") for this_stim in experiment_json["python_stims"].keys(): python_message = python_message + "...<br> saving the stimuli <b>" + this_stim + "</b>" eel.python_bootbox(python_message) print(this_stim) try: this_stim_file = open("web/User/Experiments/" + experiment_name + "/" + this_stim, "w", newline='') this_stim_file.write(experiment_json["python_stims"][this_stim]) except: print("error here"); errors += "...<br><span class='text-danger'>Error when trying to save <b>" + \ this_stim + \ "</b> - is the file open on your computer?</span>" eel.python_bootbox(python_message) finally: print("moving on") if errors == "": eel.python_hide_bb() else: eel.python_bootbox(python_message + errors)