def __init__(self): projName = self.__class__.__name__ manager = Manager() if manager.hasProject(projName): self.project = manager.loadProject(projName) else: self.project = manager.createProject(projName) # Use graph view as default settings = self.project.getSettings() settings.setRunsView(1) # graph view settings.write() self.loadWorkflow()
def _select(self): projName = self.projName.get().strip() projLocation = self.projLocation.get().strip() copyFiles = self.tkCheckVar.get() != 0 searchLocation = self.searchLocation.get().strip() manager = Manager() # If project name is empty we will use the same name as the source if not projName: projName = os.path.basename(projLocation) errorMessage = '' # Validate that project location is not empty if not projLocation: errorMessage = "Project location is empty\n" # Validate that project location exists elif not os.path.exists(projLocation): errorMessage += "Project location does not exist\n" # Validate that project location is a directory elif not os.path.isdir(projLocation): errorMessage += "Project location is not a directory\n" # Validate that the project location is a scipion project folder elif not os.path.exists(os.path.join(projLocation, PROJECT_DBNAME)): errorMessage += "Project location doesn't look like a scipion folder\n" # Validate that there isn't already a project with the same name if manager.hasProject(projName): errorMessage += "Project [%s] already exists\n" % projName # Validate that search location exists if searchLocation: if not os.path.exists(searchLocation): errorMessage += "Raw files location does not exist\n" # Validate that search location is a directory elif not os.path.isdir(searchLocation): errorMessage += "Raw files location is not a directory\n" if errorMessage: showError("Validation error", errorMessage, self.root) else: self.parent.importProject(projLocation, copyFiles, projName, searchLocation) self.close()
n = len(sys.argv) if n <> 2: usage("This script accepts 1 parameter: the project name.") projName = sys.argv[1] path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'gui', 'no-tkinter') sys.path.insert(1, path) # Create a new project manager = Manager() if not manager.hasProject(projName): usage("There is no project with this name: %s" % pwutils.red(projName)) # the project may be a soft link which may be unavailable to the cluster so get the real path try: projectPath = os.readlink(manager.getProjectPath(projName)) except: projectPath = manager.getProjectPath(projName) project = Project(projectPath) project.load() runs = project.getRuns() # Now assuming that there is no dependencies between runs # and the graph is lineal
sys.exit(1) argc = len(sys.argv) if argc < 3 or argc > 4: usage("Incorrect number of input parameters") projName = sys.argv[1] protId = sys.argv[2] n = int(sys.argv[3]) if argc == 4 else 3 # Create a new project manager = Manager() if not manager.hasProject(projName): usage("Unexistent project: %s" % pwutils.red(projName)) project = manager.loadProject(projName) protExtractParts = project.getProtocol(protId) protVol = project.getProtocol(1256) protRelionAllParts = project.getProtocol(1291) protRelionBestParts = project.getProtocol(1359) project.launchProtocol(protRelionAllParts, wait=True) project.launchProtocol(protRelionBestParts, wait=True) for i in range(n): protSubSet = project.newProtocol(em.ProtSubSet,
sys.exit(1) n = len(sys.argv) if n < 2 or n > 4: usage("Incorrect number of input parameters") projName = sys.argv[1] jsonFile = None if n < 3 else os.path.abspath(sys.argv[2]) location = None if n < 4 else sys.argv[3] path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'gui', 'no-tkinter') sys.path.insert(1, path) # Create a new project manager = Manager() if manager.hasProject(projName): usage("There is already a project with this name: %s" % pwutils.red(projName)) if jsonFile is not None and not os.path.exists(jsonFile): usage("Unexistent json file: %s" % pwutils.red(jsonFile)) project = manager.createProject(projName, location=location) if jsonFile is not None: protDict = project.loadProtocols(jsonFile)
class ProjectsView(tk.Frame): def __init__(self, parent, windows, **args): tk.Frame.__init__(self, parent, bg='white', **args) self.windows = windows self.manager = windows.manager self.root = windows.root #tkFont.Font(size=12, family='verdana', weight='bold') bigSize = pwgui.cfgFontSize + 2 smallSize = pwgui.cfgFontSize - 2 fontName = pwgui.cfgFontName self.projNameFont = tkFont.Font(size=bigSize, family=fontName, weight='bold') self.projDateFont = tkFont.Font(size=smallSize, family=fontName) self.projDelFont = tkFont.Font(size=smallSize, family=fontName, weight='bold') self.manager = Manager() btn = HotButton(self, text=Message.LABEL_CREATE_PROJECT, font=self.projNameFont, command=self._onCreateProject) btn.grid(row=0, column=0, sticky='nw', padx=10, pady=10) self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) text = TaggedText(self, width=40, height=15, bd=0, bg='white') text.grid(row=1, column=0, sticky='news') self.createProjectList(text) text.setReadOnly(True) self.text = text def createProjectList(self, text): """Load the list of projects""" r = 0 text.setReadOnly(False) text.clear() parent = tk.Frame(text, bg='white') parent.columnconfigure(0, weight=1) colors = ['white', '#EAEBFF'] for i, p in enumerate(self.manager.listProjects()): project = self.manager.loadProject(p.getName(), chdir=False) # Add creation time to project info p.cTime = project.getCreationTime() frame = self.createProjectLabel(parent, p, color=colors[i%2]) frame.grid(row=r, column=0, padx=10, pady=5, sticky='new') r += 1 text.window_create(tk.INSERT, window=parent) text.bindWidget(parent) text.setReadOnly(True) def createProjectLabel(self, parent, projInfo, color): frame = tk.Frame(parent, bg=color) label = tk.Label(frame, text=projInfo.projName, anchor='nw', bg=color, justify=tk.LEFT, font=self.projNameFont, cursor='hand1', width=50) label.grid(row=0, column=0, padx=2, pady=2, sticky='nw') label.bind('<Button-1>', lambda e: self.openProject(projInfo.projName)) dateMsg = '%s%s %s%s' % (Message.LABEL_MODIFIED, prettyDate(projInfo.mTime), Message.LABEL_CREATED, prettyTime(projInfo.cTime, time=False)) dateLabel = tk.Label(frame, text=dateMsg, font=self.projDateFont, bg=color) dateLabel.grid(row=1, column=0, sticky='nw') delLabel = tk.Label(frame, text=Message.LABEL_DELETE_PROJECT, font=self.projDelFont, bg=color, cursor='hand1') delLabel.grid(row=1, column=1, padx=10) delLabel.bind('<Button-1>', lambda e: self.deleteProject(projInfo.projName)) mvLabel = tk.Label(frame, text=Message.LABEL_RENAME_PROJECT, font=self.projDelFont, bg=color, cursor='hand1') mvLabel.grid(row=1, column=2) mvLabel.bind('<Button-1>', lambda e: self.renameProject(projInfo.projName)) return frame def createNewProject(self, projName, projLocation): self.manager.createProject(projName, location=projLocation) self.createProjectList(self.text) self.openProject(projName) def _onCreateProject(self, e=None): projWindow = ProjectCreateWindow("Create project", self) projWindow.show() def openProject(self, projName): from subprocess import Popen script = pw.join('apps', 'pw_project.py') Popen([os.environ['SCIPION_PYTHON'], script, projName]) def deleteProject(self, projName): if askYesNo(Message.TITLE_DELETE_PROJECT, "Project *%s*. " % projName + Message.MESSAGE_DELETE_PROJECT, self.root): self.manager.deleteProject(projName) self.createProjectList(self.text) def renameProject(self, projName): newName = askString("Rename project %s" % projName, "Enter new name:", self.root) if not newName or newName == projName: return if self.manager.hasProject(newName): showError("Rename cancelled", "Project name already exists: %s" % newName, self.root) return self.manager.renameProject(projName, newName) self.createProjectList(self.text)
""" % error sys.exit(1) n = len(sys.argv) if n < 2 or n > 4: usage("Incorrect number of input parameters") projName = sys.argv[1] jsonFile = None if n < 3 else os.path.abspath(sys.argv[2]) location = None if n < 4 else sys.argv[3] path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'gui', 'no-tkinter') sys.path.insert(1, path) # Create a new project manager = Manager() if manager.hasProject(projName): usage("There is already a project with this name: %s" % pwutils.red(projName)) if jsonFile is not None and not os.path.exists(jsonFile): usage("Unexistent json file: %s" % pwutils.red(jsonFile)) project = manager.createProject(projName, location=location) if jsonFile is not None: protDict = project.loadProtocols(jsonFile)
help='Scipion processes to run in parallel') parser.add_argument('project', type=str, help='Scipion project') parser.add_argument('directory', type=str, help='Directory to monitor') args = parser.parse_args() PROJECT = args.project VOLTAGE = args.voltage SAMPLING_RATE = args.sampling_rate PROCESSES = args.processes POOL = Pool(processes=PROCESSES) # Create or load project manager = Manager() if manager.hasProject(PROJECT): project = manager.loadProject(PROJECT) else: project = manager.createProject(PROJECT) # First, start up watchdog event_handler = MyEventHandler() observer = Observer() observer.schedule(event_handler, path=args.directory, recursive=False) observer.start() print('Watchdog started; to exit, press Control-C') # Second, run all existing files for f in os.listdir(args.directory): try: ext = os.path.splitext(f)[1].split('.')[1]