def delete_project(request): manager = Manager() if request.is_ajax(): projectName = request.GET.get('projectName') manager.deleteProject(projectName) return HttpResponse(mimetype='application/javascript')
def delete_project(request): manager = Manager() if request.is_ajax(): projectName = getVarFromRequest(request, PROJECT_NAME) manager.deleteProject(projectName) return HttpResponse(content_type='application/javascript')
def test_create(self): """Test the list with several Complex""" cwd = os.getcwd() manager = Manager() projectName = "TestProjectCreate" project = manager.createProject(projectName) self.assertNotEqual(cwd, os.getcwd()) self.assertEqual(project.getPath(), os.getcwd()) os.chdir(cwd) manager.deleteProject(projectName)
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)
n = len(sys.argv) if n > 3: usage("Incorrect number of input parameters") delete = '--delete' in sys.argv arg1 = sys.argv[1] if n > 1 and arg1 != '--delete': customUserData = arg1 else: customUserData = os.environ['SCIPION_USER_DATA'] print "Loading projects from:\n", customUserData # Create a new project manager = Manager(SCIPION_USER_DATA=customUserData) for projInfo in manager.listProjects(): projName = projInfo.getName() proj = manager.loadProject(projName) settings = proj.getSettings() leftTime = proj.getLeftTime() if (leftTime is not None and leftTime.days < 0): if delete: print "Deleting: %s (%s) " % (projName, leftTime) manager.deleteProject(projName) else: print "Should delete: %s (%s)" % (projName, leftTime)
delete = '--delete' in sys.argv arg1 = sys.argv[1] if n > 1 and arg1 != '--delete': customUserData = arg1 else: customUserData = os.environ['SCIPION_USER_DATA'] print "Loading projects from:\n", customUserData # Create a new project manager = Manager(SCIPION_USER_DATA=customUserData) for projInfo in manager.listProjects(): projName = projInfo.getName() proj = manager.loadProject(projName) settings = proj.getSettings() leftTime = proj.getLeftTime() if (leftTime is not None and leftTime.days < 0): if delete: print "Deleting: %s (%s) " % (projName, leftTime) manager.deleteProject(projName) else: print "Should delete: %s (%s)" % (projName, leftTime)