def openProject(projectName): """ Opens a scipion project: :param projectName: Name of a existing project to open, or "here" to create a project in the current working dir, or "last" to open the most recent project """ manager = Manager() projName = os.path.basename(projectName) # Handle special name 'here' to create a project # from the current directory if projName == 'here': cwd = Config.SCIPION_CWD if " " in cwd: print("Projects can't have spaces in the name: %s" % cwd) sys.exit(1) print("\nYou are trying to create a project here:", pwutils.cyan(cwd)) if os.listdir(cwd): print(pwutils.red('\nWARNING: this folder is not empty!!!')) key = input("\nDo you want to create a project here? [y/N]?") if key.lower().strip() != 'y': print("\nAborting...") sys.exit(0) else: print("\nCreating project....") projName = os.path.basename(cwd) projDir = os.path.dirname(cwd) manager.createProject(projName, location=projDir) elif projName == 'last': # Get last project projects = manager.listProjects() if not projects: sys.exit("No projects yet, cannot open the last one.") projName = projects[0].projName projPath = manager.getProjectPath(projName) projWindow = ProjectWindow(projPath) projWindow.show()
print "ERROR: ", msg print "\nUSAGE: scipion tutorial [TUTORIAL_NAME]" print "\nwhere TUTORIAL_NAME can be:" print "\n".join([' %s' % k for k in ALL_TUTORIALS.keys()]) if pwutils.envVarOn('SCIPION_DEBUG'): # Add callback for remote debugging if available. try: from rpdb2 import start_embedded_debugger from signal import signal, SIGUSR2 signal(SIGUSR2, lambda sig, frame: start_embedded_debugger('a')) except ImportError: pass if len(sys.argv) == 2: manager = Manager() tutorialName = sys.argv[1] if not tutorialName in ALL_TUTORIALS: printUsage("Invalid tutorial '%s'." % tutorialName) else: # Instanciate the proper tutorial class tutorial = ALL_TUTORIALS[tutorialName]() projWindow = ProjectWindow(tutorial.project.getName()) projWindow.show() else: msg = 'Too many arguments.' if len(sys.argv) > 2 else '' printUsage(msg)