Пример #1
0
    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
Пример #2
0
def run_scipion_qc(movie_file):

    manager = Manager()
    project = manager.loadProject(PROJECT)
    path, pattern = os.path.split(movie_file)

    add_movies = project.newProtocol(
        ProtImportMovies,
        filesPath=path,
        filesPattern=pattern,
        voltage=VOLTAGE,
        samplingRate=SAMPLING_RATE,
    )
    project.launchProtocol(add_movies, wait=True)

    align_movies = project.newProtocol(
        ProtMovieAlignment,
        inputMovies=add_movies.outputMovies,
    )
    project.launchProtocol(align_movies, wait=True)

    find_ctf = project.newProtocol(
        ProtCTFFind,
        inputMicrographs=align_movies.outputMicrographs,
    )
    project.launchProtocol(find_ctf, wait=False)
Пример #3
0
    def test_createNoChdir(self):
        """Test the list with several Complex"""
        cwd = os.getcwd()
        manager = Manager()
        projectName = "TestProjectCreate"
        project = manager.createProject(projectName, chdir=False)
        dataset = DataSet.getDataSet('emx')

        prot1 = project.newProtocol(
            em.ProtImportParticles,
            objLabel='from emx (coordinatesT1)',
            importFrom=em.ProtImportParticles.IMPORT_FROM_EMX,
            emxFile=dataset.getFile('coordinatesT1'),
            alignType=3,
            voltage=100,
            magnification=10000,
            samplingRate=2.46)
        project.launchProtocol(prot1, wait=True)

        # Execute a copy of prot1
        prot2 = project.copyProtocol(prot1)
        project.launchProtocol(prot2, wait=True)

        # Now restart prot2
        prot2.runMode.set(MODE_RESTART)
        project.launchProtocol(prot2, wait=True)

        #self.assertEqual(cwd, project.getPath())
        self.assertEqual(cwd, os.getcwd())
Пример #4
0
def delete_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = request.GET.get('projectName')
        manager.deleteProject(projectName)

    return HttpResponse(mimetype='application/javascript')
Пример #5
0
def delete_project(request):
    manager = Manager()
    
    if request.is_ajax():
        projectName = request.GET.get('projectName')
        manager.deleteProject(projectName)       
        
    return HttpResponse(mimetype='application/javascript')
Пример #6
0
def delete_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = getVarFromRequest(request, PROJECT_NAME)
        manager.deleteProject(projectName)

    return HttpResponse(content_type='application/javascript')
Пример #7
0
def create_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = getVarFromRequest(request, PROJECT_NAME)
        workflow = getVarFromRequest(request, WORKFLOW)
        manager.createProject(projectName, chdir=False, workflow=workflow)

    return HttpResponse(content_type='application/javascript')
Пример #8
0
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()):
            try:
                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
            except Exception, ex:
                print "ERROR loading project: %s" % p.getName()
                print ex
        text.window_create(tk.INSERT, window=parent)
        text.bindWidget(parent)
        text.setReadOnly(True)
Пример #9
0
    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)
Пример #10
0
def setupTestProject(cls):
    """ Create and setup a Project for a give Test class. """
    projName = cls.__name__
    if os.environ.get('SCIPION_TEST_CONTINUE', None) == '1':
        proj = Manager().loadProject(projName)
    else:
        proj = Manager().createProject(
            projName)  # Now it will be loaded if exists

    cls.outputPath = proj.path
    cls.projName = projName
    cls.proj = proj
Пример #11
0
 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()
Пример #12
0
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()):
            try:
                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
            except Exception, ex:
                print "ERROR loading project: %s" % p.getName()
                print ex
        text.window_create(tk.INSERT, window=parent)
        text.bindWidget(parent)
        text.setReadOnly(True)
Пример #13
0
def setupTestProject(cls):
    """ Create and setup a Project for a give Test class. """
    projName = cls.__name__
    if os.environ.get('SCIPION_TEST_CONTINUE', None) == '1':
        proj = Manager().loadProject(projName)
    else:
        proj = Manager().createProject(projName) # Now it will be loaded if exists

    
    cls.outputPath = proj.path
    # Create project does not change the working directory anymore
    os.chdir(cls.outputPath)
    cls.projName = projName
    cls.proj = proj
Пример #14
0
def getServiceManager(serviceName):
    print "getServiceManager"
    print "serviceName: ", serviceName
    scipionUserData = os.path.join(os.environ['SCIPION_USER_DATA'], serviceName)
    manager = Manager(SCIPION_USER_DATA = scipionUserData)
    
    manager.config = os.path.join(os.environ['HOME'], '.config', 'scipion', serviceName)
    manager.protocols = os.path.join(manager.config, 'protocols.conf')
    manager.hosts = os.path.join(manager.config, 'hosts.conf')
    
    print "config: ", manager.config
    print "protocols: ", manager.protocols
    print "hosts: ", manager.hosts
    
    return manager
Пример #15
0
 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
Пример #16
0
    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()
Пример #17
0
def project_content(request):
    projectName = request.GET.get('projectName', None)
    if projectName is None:
        projectName = request.POST.get('projectName', None)
    project = Manager().loadProject(projectName)
    context = contentContext(request, project)
    context.update({'mode': None, 'formUrl': 'form'})
    return render_to_response('project_content/project_content.html', context)
Пример #18
0
    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()
Пример #19
0
def getServiceManager(serviceName):
    print "getServiceManager"
    print "serviceName: ", serviceName
    scipionUserData = os.path.join(os.environ['SCIPION_USER_DATA'],
                                   serviceName)
    manager = Manager(SCIPION_USER_DATA=scipionUserData)

    serviceConf = os.path.join(os.environ['HOME'], '.config', 'scipion',
                               serviceName)
    manager.config = os.path.join(serviceConf, 'scipion.conf')
    manager.protocols = os.path.join(serviceConf, 'protocols.conf')
    manager.hosts = os.path.join(serviceConf, 'hosts.conf')

    print "config: ", manager.config
    print "protocols: ", manager.protocols
    print "hosts: ", manager.hosts

    return manager
Пример #20
0
def projects(request):
    from pyworkflow.utils.utils import prettyDate
    
    manager = Manager()
    projects = manager.listProjects()
    for p in projects:
        p.pTime = prettyDate(p.mTime)

    if 'projectName' in request.session: request.session['projectName'] = ""
    if 'projectPath' in request.session: request.session['projectPath'] = ""

    context = {'projects': projects,
               'projects_css': getResourceCss('projects'),
               'project_utils_js': getResourceJs('project_utils'),
               }
    
    context = base_grid(request, context)
    
    return render_to_response('projects.html', context)
Пример #21
0
def project_content(request):
    projectName = getVarFromRequest(request, PROJECT_NAME)
    mode = getVarFromRequest(request, MODE)
    project = Manager().loadProject(projectName, chdir=False)
    context = contentContext(request, project)
    context.update({'mode': mode, 'formUrl': 'form'})

    if mode == MODE_WORKFLOW:
        context.update({'nowest': True})

    return render_to_response('project_content/project_content.html', context)
Пример #22
0
def projects(request):
    from pyworkflow.utils.utils import prettyDate

    manager = Manager()
    projects = manager.listProjects()
    for p in projects:
        p.pTime = prettyDate(p.mTime)

    if 'projectName' in request.session: request.session['projectName'] = ""
    if 'projectPath' in request.session: request.session['projectPath'] = ""

    context = {
        'projects': projects,
        'projects_css': getResourceCss('projects'),
        'project_utils_js': getResourceJs('project_utils'),
    }

    context = base_grid(request, context)

    return render_to_response('projects.html', context)
    def _writeSubset(self, subset):
        """ Generated the output of this subset. """
        newSubsetName = 'outputParticles_%03d' % self._counter
        self.info("Creating new subset: %s" % newSubsetName)
        subset.write()
        self._defineOutputs(**{newSubsetName: subset})
        self._defineTransformRelation(self.inputParticles, subset)
        # The following is required to commit the changes to the database
        self._store(subset)
        subset.close()

        from pyworkflow.manager import Manager
        manager = Manager()
        project = manager.loadProject(self.getProject().getName())
        input2D = self.input2dProtocol.get()
        copyProt = project.copyProtocol(project.getProtocol(input2D.getObjId()))
        copyProt.inputParticles.set(project.getProtocol(self.getObjId()))
        copyProt.inputParticles.setExtended(newSubsetName)
        project.scheduleProtocol(copyProt, self._runPrerequisites)
        # Next schedule will be after this one
        self._runPrerequisites.append(copyProt.getObjId())
Пример #24
0
def getServiceManager(serviceName):
    global SERVICE_MANAGERS

    manager = SERVICE_MANAGERS.get(serviceName, None)

    if manager is None:
        print "...Creating new cached Manager"
        scipionUserData = os.environ['SCIPION_USER_DATA']
        servicePath = '' if serviceName is None else serviceName
        scipionUserData = os.path.join(scipionUserData, servicePath)

        manager = Manager(SCIPION_USER_DATA=scipionUserData)

        serviceConf = os.path.join(os.environ['HOME'], '.config', 'scipion',
                                   servicePath)
        manager.config = os.path.join(serviceConf, 'scipion.conf')
        manager.protocols = os.path.join(serviceConf, 'protocols.conf')
        manager.hosts = os.path.join(serviceConf, 'hosts.conf')
        SERVICE_MANAGERS[serviceName] = manager

    return manager
Пример #25
0
def data_content(request):        
    projectName = request.GET.get('projectName', None)
    
    manager = Manager()
    request.session['projectPath'] = manager.getProjectPath(projectName)
    project = loadProject(request)
    
    context = {'projectName': projectName,
               'editTool': getResourceIcon('edit_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'data_content_utils': getResourceJs('data_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css':getResourceCss('project_content'),
               'view':'data'
               }
    
    context = base_flex(request, context)
    
    return render_to_response('data_content/data_content.html', context)
Пример #26
0
def data_content(request):
    projectName = getVarFromRequest(request, PROJECT_NAME)

    manager = Manager()
    request.session[CTX_PROJECT_PATH] = manager.getProjectPath(projectName)
    # project = loadProject(request)

    context = {CTX_PROJECT_NAME: projectName,
               'editTool': getResourceIcon('edit_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'data_content_utils': getResourceJs('data_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css': getResourceCss('project_content'),
               'view': 'data'
               }

    context = base_flex(request, context)

    return render_to_response('data_content/data_content.html', context)
Пример #27
0
def projects(request):
    from pyworkflow.utils.utils import prettyDate

    manager = Manager()
    projectsList = manager.listProjects()
    for p in projectsList:
        p.pTime = prettyDate(p.mTime)

    if CTX_PROJECT_NAME in request.session:
        request.session[CTX_PROJECT_NAME] = ""
    if CTX_PROJECT_PATH in request.session:
        request.session[CTX_PROJECT_PATH] = ""

    context = {
        'projects': projectsList,
        'projects_css': getResourceCss('projects'),
        'project_utils_js': getResourceJs('project_utils'),
        'workflows': json.dumps(getWorkflowsList())
    }

    context = base_grid(request, context)

    return render_to_response('projects.html', context)
    def __init__(self, config, **kwargs):
        try:
            title = '%s (%s on %s)' % (Message.LABEL_PROJECTS,
                                       pwutils.getLocalUserName(),
                                       pwutils.getLocalHostName())
        except Exception:
            title = Message.LABEL_PROJECTS

        settings = ProjectSettings()
        self.generalCfg = settings.getConfig()

        self.config = config
        ProjectBaseWindow.__init__(self, title, minsize=(400, 550), **kwargs)
        self.viewFuncs = {VIEW_WIZARD: BoxWizardView}
        self.manager = Manager()
        self.switchView(VIEW_WIZARD)
Пример #29
0
def check_project_id(request):
    result = 0
    projectName = request.GET.get('code', None)
    serviceName = request.GET.get('serviceName', None)

    try:
        if serviceName is None:
            project = Manager().loadProject(projectName)
        else:
            manager = getServiceManager(serviceName)
            project = manager.loadProject(projectName,
                                          protocolsConf=manager.protocols,
                                          hostsConf=manager.hosts)
        result = 1
    except Exception:
        pass

    return HttpResponse(result, mimetype='application/javascript')
Пример #30
0
    def __init__(self, **kwargs):
        # Load global configuration
        settings = ProjectSettings()

        # TODO: put the menu part more nicely. From here:
        menu = MenuConfig()

        fileMenu = menu.addSubMenu('File')
        fileMenu.addSubMenu('Browse files',
                            'browse',
                            icon='fa-folder-open.png')
        fileMenu.addSubMenu('Exit', 'exit', icon='fa-sign-out.png')

        confMenu = menu.addSubMenu('Configuration')
        confMenu.addSubMenu('General', 'general')
        confMenu.addSubMenu('Hosts', 'hosts')
        confMenu.addSubMenu('Protocols', 'protocols')
        confMenu.addSubMenu('User', 'user')

        helpMenu = menu.addSubMenu('Help')
        helpMenu.addSubMenu('Online help',
                            'online_help',
                            icon='fa-external-link.png')
        helpMenu.addSubMenu('About', 'about', icon='fa-question-circle.png')

        self.menuCfg = menu
        self.generalCfg = settings.getConfig()

        try:
            title = '%s (%s on %s)' % (Message.LABEL_PROJECTS,
                                       pwutils.getLocalUserName(),
                                       pwutils.getLocalHostName())
        except Exception:
            title = Message.LABEL_PROJECTS

        ProjectBaseWindow.__init__(self, title, minsize=(750, 500), **kwargs)
        self.manager = Manager()

        self.switchView(VIEW_PROJECTS)
Пример #31
0
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)
    
Пример #32
0
    """ % 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)
Пример #33
0
    """ % error
    sys.exit(1)


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()
Пример #34
0
from pyworkflow.gui.project import ProjectWindow
import pyworkflow.utils as pwutils


if __name__ == '__main__':

    # 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) > 1:
        manager = Manager()
        projName = os.path.basename(sys.argv[1])

        # Handle special name 'here' to create a project
        # from the current directory
        if projName == 'here':
            cwd = os.environ['SCIPION_CWD']
            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 = raw_input("\nDo you want to create a project here? [y/N]?")

            if key.lower().strip() != 'y':
                print "\nAborting..."
                sys.exit(0)
Пример #35
0
if n < 2 or n > 3:
    usage("Incorrect number of input parameters")
    
jsonFn = os.path.abspath(sys.argv[1])

now = datetime.now()
tempSpace = "editor-%s" % now.strftime('%Y%m%d-%H%M%S')
customUserData = os.path.join(os.environ['SCIPION_USER_DATA'],
                              'tmp', tempSpace)

pwutils.makePath(os.path.join(customUserData, 'projects'))

print "Loading projects from:\n", customUserData 
 
# Create a new project
manager = Manager(SCIPION_USER_DATA=customUserData)

projName = os.path.basename(jsonFn)
proj = manager.createProject(projName)
projPath = manager.getProjectPath(projName)
proj.loadProtocols(jsonFn)

class EditorProjectWindow(ProjectWindow):
    def close(self, e=None):
        try:
            print "Writing protocols to: ", jsonFn
            proj.getRunsGraph() # Build project runs graph
            proj.exportProtocols(proj.getRuns(), jsonFn)
            print "Deleting temporary folder: ", customUserData
            pwutils.cleanPath(customUserData)
        except Exception, ex:
Пример #36
0
ALL_RELATIONS = 'all'


def usage(error):
    print """
    ERROR: %s
    
    """ % error
    sys.exit(1)


delete = '--delete' in sys.argv

# Create a new project
manager = Manager()
missing = []

for projName in os.listdir(manager.PROJECTS):
    entry = manager.getProjectPath(projName)
    #print " entry: ", entry, " islink: ", os.path.islink(entry), " exists: ", os.path.exists(entry)
    if os.path.islink(entry) and not os.path.exists(entry):
        missing.append(entry)

if missing:
    print "Missing projects:"
    print " \n".join(missing)

    if delete:
        for entry in missing:
            print "Removing: ", entry
Пример #37
0
n = len(sys.argv)

if n < 2 or n > 5:
    usage("Incorrect number of input parameters")
fromLocation = sys.argv[1]
projName = fromLocation.rsplit('/', 1)[-1] if n < 3 else sys.argv[2]

jsonFile = None if n < 4 else os.path.abspath(sys.argv[3])
location = None if n < 5 else sys.argv[4]

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))

project = manager.createProject(projName, location=location)
# copy sqlite and make links of runs
pwutils.copyFile(os.path.join(fromLocation, PROJECT_DBNAME), project.path)
fromRuns = os.path.join(fromLocation, PROJECT_RUNS)
for r in os.listdir(fromRuns):
    print " %s,%s" % (os.path.join(fromRuns,
                                   r), os.path.join(project.runsPath, r))
    pwutils.createAbsLink(os.path.join(fromRuns, r),
                          os.path.join(project.runsPath, r))
Пример #38
0
now = datetime.now()
tempSpace = "loading-%s" % now.strftime('%Y%m%d-%H%M%S')
customUserData = os.path.join(os.environ['SCIPION_USER_DATA'],
                              'tmp', tempSpace)

projectsDir = os.path.join(customUserData, 'projects')
pwutils.makePath(projectsDir)

print "Loading projects from:\n", projectsDir

projName = os.path.basename(pathToProj)
pwutils.createAbsLink(pathToProj, os.path.join(projectsDir, projName))
 
# Create a new project
manager = Manager(SCIPION_USER_DATA=customUserData)

proj = manager.loadProject(projName)
projPath = manager.getProjectPath(projName)

class EditorProjectWindow(ProjectWindow):
    def close(self, e=None):
        try:
            print "Deleting temporary folder: ", customUserData
            pwutils.cleanPath(customUserData)
        except Exception, ex:
            print "Error: ", ex
        ProjectWindow.close(self, e)

projWindow = EditorProjectWindow(projPath)
projWindow.show()
Пример #39
0
        N: the number of times to repeat the workflow.
    """ % error
    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)
Пример #40
0
    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)
Пример #41
0
    Usage: scipion python export_particles.py PROJECT PROCOTOL
        PROJECT: provide the project name
        PROCOTOL: provide the protocol id to be used as input.
    """ % error
    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]

manager = Manager()

if not manager.hasProject(projName):
    usage("Unexistent project: %s" % pwutils.red(projName))

project = manager.loadProject(projName)

prot = project.getProtocol(protId)

if prot is None:
    usage("Unexistent protocol: %s" % protId)

outputParticles = getattr(prot, 'outputParticles', None)

if outputParticles is None:
    usage("Protocol does not have 'outputParticles'")
Пример #42
0
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)
Пример #43
0
    sys.exit(1)


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()
Пример #44
0
            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)
Пример #45
0
from pyworkflow.gui.project import ProjectWindow



if __name__ == '__main__':

    # 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) > 1:
        manager = Manager()
        projName = os.path.basename(sys.argv[1])
        if 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)
        try:
            projWindow = ProjectWindow(projPath)
        except Exception as e:
            sys.exit(e)
        projWindow.show()
    else:
        print "usage: pw_project.py PROJECT_NAME"
Пример #46
0
    def _createScipionProject(self, projName, projPath, scipionProjPath):
        manager = Manager()
        project = manager.createProject(projName, location=scipionProjPath)
        self.lastProt = None
        pattern = self._getConfValue(PATTERN)

        smtpServer = self._getConfValue(SMTP_SERVER, '')
        smtpFrom = self._getConfValue(SMTP_FROM, '')
        smtpTo = self._getConfValue(SMTP_TO, '')
        doMail = self._getValue(EMAIL_NOTIFICATION) 
        doPublish = self._getValue(HTML_REPORT)

        protImport = project.newProtocol(em.ProtImportMovies,
                                         objLabel='Import movies',
                                         filesPath=projPath,
                                         filesPattern=pattern,
                                         sphericalAberration=self._getConfValue(CS),
                                         dataStreaming=True)

        # Should I publish html report?       
        if doPublish == 1:
            publish = self._getConfValue('HTML_PUBLISH')
            print("\n\nReport available at URL: %s/%s\n\n"
                  %('http://scipion.cnb.csic.es/scipionbox',projName))
        else:
            publish = ''

        protMonitor = project.newProtocol(em.ProtMonitorSummary,
                                          objLabel='Summary Monitor',
                                          doMail=doMail,
                                          emailFrom=smtpFrom,
                                          emailTo=smtpTo,
                                          smtp=smtpServer,
                                          publishCmd=publish)

        def _saveProtocol(prot, movies=True, monitor=True):
            if movies:
                prot.inputMovies.set(self.lastProt)
                prot.inputMovies.setExtended('outputMovies')
            project.saveProtocol(prot)
            self.lastProt = prot
            if monitor:
                protMonitor.inputProtocols.append(prot)

        _saveProtocol(protImport, movies=False)

        useMC2 = self._getValue(MOTIONCOR2)
        useMC = self._getValue(MOTIONCORR) or useMC2
        useOF = self._getValue(OPTICAL_FLOW)
        useSM = self._getValue(SUMMOVIE)
        useCTF = self._getValue(CTFFIND4)
        useGCTF = self._getValue(GCTF)

        kwargs = {}
        frames = self._getValue(FRAMES_RANGE).split()
        if frames:
            kwargs['alignFrame0'] = kwargs['sumFrame0'] = frames[0]
            kwargs['alignFrameN'] = kwargs['sumFrameN'] = frames[1]

        if useMC:
            # Create motioncorr
            from pyworkflow.em.packages.motioncorr import ProtMotionCorr
            protMC = project.newProtocol(ProtMotionCorr,
                                         objLabel='Motioncorr',
                                         useMotioncor2=useMC2,
                                         **kwargs)
            _saveProtocol(protMC)

        if useOF:
            # Create Optical Flow protocol
            from pyworkflow.em.packages.xmipp3 import XmippProtOFAlignment

            protOF = project.newProtocol(XmippProtOFAlignment,
                                         objLabel='Optical Flow',
                                         doSaveMovie=useSM,
                                         **kwargs)
            _saveProtocol(protOF)

        if useSM:
            # If OF write the movie, then we need to reset frames count
            if frames and useOF:
                kwargs['alignFrame0'] = kwargs['sumFrame0'] = 1
                kwargs['alignFrameN'] = kwargs['sumFrameN'] = 0

            from pyworkflow.em.packages.grigoriefflab import ProtSummovie
            protSM = project.newProtocol(ProtSummovie,
                                         objLabel='Summovie',
                                         cleanInputMovies=useOF,
                                         numberOfThreads=1,
                                         **kwargs)
            _saveProtocol(protSM)

        lastBeforeCTF = self.lastProt

        if useCTF:
            from pyworkflow.em.packages.grigoriefflab import ProtCTFFind
            protCTF = project.newProtocol(ProtCTFFind,
                                          objLabel='Ctffind',
                                          numberOfThreads=1)
            protCTF.inputMicrographs.set(lastBeforeCTF)
            protCTF.inputMicrographs.setExtended('outputMicrographs')
            _saveProtocol(protCTF, movies=False)

        if useGCTF:
            from pyworkflow.em.packages.gctf import ProtGctf
            protGCTF = project.newProtocol(ProtGctf,
                                           objLabel='Gctf')
            protGCTF.inputMicrographs.set(lastBeforeCTF)
            protGCTF.inputMicrographs.setExtended('outputMicrographs')
            _saveProtocol(protGCTF, movies=False)

        project.saveProtocol(protMonitor)

        os.system('%s project %s &' % (pw.getScipionScript(), projName))

        self.windows.close()