예제 #1
0
    def post(self, project_id):
        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]

        pdb = Projects()

        # Existing project.
        if int(project_id) != pdb.predict_next_rowid():
            project = pdb.get(project_id)
            project_is_new = False
        # New project
        else:
            project = {}
            project['active'] = 0
            project['projpath'] = None
            project_is_new = True

        if 'projectname' not in forms or \
           len(forms['projectname']) == 0:
            project['projectname'] = "Unnamed Project"
        else:
            project['projectname'] = forms['projectname'].strip()

        if 'description' in forms:
            project['description'] = forms['description'].strip()
        else:
            project['description'] = ''

        if 'version' in forms:
            project['version'] = forms['version'].strip()
        else:
            project['version'] = ''

        # if there's no proj dir yet, create an empty one
        if not project['projpath']:
            directory = self.get_project_dir()
            pname = project['projectname']
            project['projpath'] = _get_unique_name(directory, pname)

        if project_is_new:
            pdb.new(project)
            os.mkdir(project['projpath'])
        else:
            for key, value in project.iteritems():
                pdb.set(project_id, key, value)
            pdb.modified(project_id)

        # Update project settings.
        proj = Project(project['projpath'])
        dummy = proj.get_info()  # Just to get required keys.
        info = {}
        for key in dummy:
            info[key] = project[key]
        proj.set_info(info)

        self.redirect("/workspace/project?projpath=" + project['projpath'])
예제 #2
0
    def post(self, project_id):
        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]

        pdb = Projects()

        # Existing project.
        if int(project_id) != pdb.predict_next_rowid():
            project = pdb.get(project_id)
            project_is_new = False
        # New project
        else:
            project = {}
            project['active'] = 0
            project['projpath'] = None
            project_is_new = True

        if 'projectname' not in forms or \
           len(forms['projectname']) == 0:
            project['projectname'] = "Unnamed Project"
        else:
            project['projectname'] = forms['projectname'].strip()

        if 'description' in forms:
            project['description'] = forms['description'].strip()
        else:
            project['description'] = ''

        if 'version' in forms:
            project['version'] = forms['version'].strip()
        else:
            project['version'] = ''

        # if there's no proj dir yet, create an empty one
        if not project['projpath']:
            directory = self.get_project_dir()
            pname = project['projectname']
            project['projpath'] = _get_unique_name(directory, pname)

        if project_is_new:
            pdb.new(project)
            os.mkdir(project['projpath'])
        else:
            for key, value in project.iteritems():
                pdb.set(project_id, key, value)
            pdb.modified(project_id)

        # Update project settings.
        proj = Project(project['projpath'])
        dummy = proj.get_info()  # Just to get required keys.
        info = {}
        for key in dummy:
            info[key] = project[key]
        proj.set_info(info)

        self.redirect("/workspace/project?projpath=" + project['projpath'])
예제 #3
0
    def post(self):

        pdb = Projects()

        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]

        project = {}
        project['projectname'] = forms['projectname'].strip()
        project['description'] = forms['description'].strip()
        project['version'] = forms['version'].strip()
        project['id'] = pdb.predict_next_rowid()
        project['active'] = 1

        # figure out a unique directory name for the project using
        #   the project name and version string
        directory = self.get_project_dir()
        version = project['version']
        pname = project['projectname']
        if len(version):
            filename = clean_filename('%s-%s' % (pname, version))
        else:
            filename = clean_filename(pname)

        unique = filename
        i = 1
        while os.path.exists(os.path.join(directory, unique)):
            unique = '%s_%s' % (filename, str(i))
            i = i + 1

        project['projpath'] = os.path.join(directory, unique)

        pdb.new(project)
        os.mkdir(project['projpath'])

        # Update project settings.
        proj = Project(project['projpath'])
        dummy = proj.get_info()  # Just to get required keys.
        info = {}
        for key in dummy:
            info[key] = project[key]
        proj.set_info(info)

        self.redirect("/workspace/project?projpath=" +
                      quote_plus(project['projpath']))
    def post(self):

        pdb = Projects()

        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]

        project = {}
        project['projectname'] = forms['projectname'].strip()
        project['description'] = forms['description'].strip()
        project['version'] = forms['version'].strip()
        project['id'] = pdb.predict_next_rowid()
        project['active'] = 1

        # figure out a unique directory name for the project using
        #   the project name and version string
        directory = self.get_project_dir()
        version = project['version']
        pname = project['projectname']
        if len(version):
            filename = clean_filename('%s-%s' % (pname, version))
        else:
            filename = clean_filename(pname)

        unique = filename
        i = 1
        while os.path.exists(os.path.join(directory, unique)):
            unique = '%s_%s' % (filename, str(i))
            i = i+1

        project['projpath'] = os.path.join(directory, unique)

        pdb.new(project)
        os.mkdir(project['projpath'])
                
        # Update project settings.
        proj = Project(project['projpath'])
        dummy = proj.get_info()  # Just to get required keys.
        info = {}
        for key in dummy:
            info[key] = project[key]
        proj.set_info(info)

        self.redirect("/workspace/project?projpath=" + project['projpath'])
예제 #5
0
    def post(self):

        sourcefile = self.request.files['myfile'][0]
        if sourcefile:
            filename = sourcefile['filename']
            if len(filename) > 0:

                unique = _get_unique_name(self.get_project_dir(),
                                          parse_archive_name(filename))

                pdb = Projects()

                project = {}
                project['id'] = pdb.predict_next_rowid()
                project['version'] = ''
                project['description'] = ''
                project['active'] = 1
                project['projectname'] = parse_archive_name(unique)
                project['projpath'] = unique

                os.mkdir(unique)

                buff = StringIO.StringIO(sourcefile['body'])

                archive = tarfile.open(fileobj=buff, mode='r:gz')
                archive.extractall(path=unique)

                vcslist = find_vcs()
                if vcslist:
                    vcs = vcslist[0](unique)
                else:
                    vcs = DumbVCS(unique)
                vcs.init_repo()

                # TODO: look for project config and retrieve project db info from it

                pdb.new(project)

                self.redirect('/projects/' + str(project['id']))

        self.redirect('')
    def post(self):

        sourcefile = self.request.files['myfile'][0]
        if sourcefile:
            filename = sourcefile['filename']
            if len(filename) > 0:

                unique = _get_unique_name(self.get_project_dir(),
                                          parse_archive_name(filename))
                
                pdb = Projects()

                project = {}
                project['id'] = pdb.predict_next_rowid()
                project['version'] = ''
                project['description'] = ''
                project['active'] = 1
                project['projectname'] = parse_archive_name(unique)
                project['projpath'] = unique

                os.mkdir(unique)
                
                buff = StringIO.StringIO(sourcefile['body'])
                
                archive = tarfile.open(fileobj=buff, mode='r:gz')
                archive.extractall(path=unique)
                
                vcslist = find_vcs()
                if vcslist:
                    vcs = vcslist[0](unique)
                else:
                    vcs = DumbVCS(unique)
                vcs.init_repo()
                
                # TODO: look for project config and retrieve project db info from it
                
                pdb.new(project)

                self.redirect('/projects/'+str(project['id']))

        self.redirect('')
    def post(self):
        
        sourcefile = self.request.files['myfile'][0]
        if sourcefile:
            filename = sourcefile['filename']
            if len(filename) > 0:
                
                pdb = Projects()
                
                timestring = strftime("%Y-%m-%d_%H%M%S")
                
                project = {}
                project['id'] = pdb.predict_next_rowid()
                project['version'] = ''
                project['description'] = ''
                project['active'] = 1

                if filename[-5:] == '.proj':
                    filename = filename[:-5]
                project['projectname']   = 'Added_%s' % (filename)
                    
                unique = '%s.proj' % filename
                i = 1
                while os.path.exists(os.path.join(self.get_project_dir(), \
                                                  unique)):
                    unique = '%s_%s.proj' % (filename, str(i))
                    i = i+1
                    
                with open(os.path.join(self.get_project_dir(), 
                                       unique), 'wb') as out:
                    out.write(sourcefile['body'])
                    out.close()
                    
                project['filename'] = unique
                pdb.new(project)
                
                self.redirect('/projects/'+str(project['id']))
                
        self.redirect('')
예제 #8
0
    def post(self):

        sourcefile = self.request.files['myfile'][0]
        if sourcefile:
            filename = sourcefile['filename']
            if len(filename) > 0:

                pdb = Projects()

                project = {}
                project['id'] = pdb.predict_next_rowid()
                project['version'] = ''
                project['description'] = ''
                project['active'] = 1

                if filename[-5:] == '.proj':
                    filename = filename[:-5]
                project['projectname'] = 'Added_%s' % (filename)

                unique = '%s.proj' % filename
                i = 1
                while os.path.exists(os.path.join(self.get_project_dir(), \
                                                  unique)):
                    unique = '%s_%s.proj' % (filename, str(i))
                    i = i+1

                with open(os.path.join(self.get_project_dir(),
                                       unique), 'wb') as out:
                    out.write(sourcefile['body'])
                    out.close()

                project['filename'] = unique
                pdb.new(project)

                self.redirect('/projects/'+str(project['id']))

        self.redirect('')
    def post(self, project_id):
        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]

        pdb = Projects()

        # Existing project.
        if int(project_id) != pdb.predict_next_rowid():
            project = pdb.get(project_id)
            project_is_new = False
        # New project
        else:
            project = {}
            project['active'] = 0
            project['projpath'] = None
            project_is_new = True

        if 'projectname' not in forms or \
           len(forms['projectname']) == 0:
            project['projectname'] = "Unnamed Project"
        else:
            project['projectname'] = forms['projectname'].strip()

        if 'description' in forms:
            project['description'] = forms['description'].strip()
        else:
            project['description'] = ''

        if 'version' in forms:
            project['version'] = forms['version'].strip()
        else:
            project['version'] = ''
            
        directory = forms.get('directory', self.get_project_dir())

        # if there's no proj dir yet, create an empty one
        if not project['projpath']:

            version = project['version']
            pname = project['projectname']

            if len(version):
                filename = clean_filename('%s-%s' % (pname, version))
            else:
                filename = clean_filename(pname)

            unique = filename
            i = 1
            while os.path.exists(os.path.join(directory, unique)):
                unique = '%s_%s' % (filename, str(i))
                i = i+1

            project['projpath'] = os.path.join(directory, unique)

        if project_is_new:
            pdb.new(project)
            os.mkdir(project['projpath'])
        else:
            for key, value in project.iteritems():
                pdb.set(project_id, key, value)
            pdb.modified(project_id)

        # Update project settings.
        proj = Project(project['projpath'])
        dummy = proj.get_info()  # Just to get required keys.
        info = {}
        for key in dummy:
            info[key] = project[key]
        proj.set_info(info)

        self.redirect("/workspace/project?projpath=" + project['projpath'])
    def post(self):

        if not self.request.arguments.has_key( "projectname" ):
            # First step in the import process.
            #   Just get the name, description and version of the
            #   project the user wants to import.
            #   Then pass this to the form so the user can change it.

            # Go through the process of creating a new project directory
            #   so we can read the name, description and version from the
            #   settings file.
            sourcefile = self.request.files['projectfile'][0]
            if sourcefile:
                filename = sourcefile['filename']
                if len(filename) > 0:
                    unique = _get_unique_name(self.get_project_dir(),
                                              parse_archive_name(filename))
                    os.mkdir(unique)
                    buff = StringIO.StringIO(sourcefile['body'])
                    archive = tarfile.open(fileobj=buff, mode='r:gz')
                    archive.extractall(path=unique)
                    vcslist = find_vcs()
                    if vcslist:
                        vcs = vcslist[0](unique)
                    else:
                        vcs = DumbVCS(unique)
                    vcs.init_repo()
    
                    # Update project dict with info section of config file.
                    proj = Project(unique)
                    
                    shutil.rmtree(unique)
    
                    project_info = proj.get_info()
                    self.render('projdb/import-metadata-fields.html',
                                projectname=parse_archive_name(unique),
                                description=project_info['description'],
                                version=project_info['version']
                                )
            self.redirect("/")
        else:
            forms = {}
            for field in ['projectname', 'description', 'version']:
                if field in self.request.arguments.keys():
                    forms[field] = self.request.arguments[field][0]


            sourcefile = self.request.files['projectfile'][0]
            if sourcefile:
                filename = sourcefile['filename']
                if len(filename) > 0:

                    unique = _get_unique_name(self.get_project_dir(),
                                              parse_archive_name(filename))
                
                    pdb = Projects()

                    project = {}
                    project['id'] = pdb.predict_next_rowid()
                    project['active'] = 1
                    project['projectname'] = forms['projectname'].strip()
                    project['description'] = forms['description'].strip()
                    project['version'] = forms['version'].strip()
                    project['projpath'] = unique

                    os.mkdir(unique)
                
                    buff = StringIO.StringIO(sourcefile['body'])
                  
                    archive = tarfile.open(fileobj=buff, mode='r:gz')
                    archive.extractall(path=unique)

                    vcslist = find_vcs()
                    if vcslist:
                        vcs = vcslist[0](unique)
                    else:
                        vcs = DumbVCS(unique)
                    vcs.init_repo()

                    # Update project settings.
                    proj = Project(project['projpath'])
                    dummy = proj.get_info()  # Just to get required keys.
                    info = {}
                    for key in dummy:
                        info[key] = project[key]
                    proj.set_info(info)

                    pdb.new(project)

                    self.redirect("/workspace/project?projpath=" + project['projpath'])

            self.redirect("/")
예제 #11
0
    def post(self):
        # The project file is uploaded once to extract the metadata.
        # It is then deleted and the metadata is used to populate another
        # import dialog, giving the user an opportunity to edit the
        # info before importing or cancel the import.
        if not 'projectname' in self.request.arguments:
            # First upload
            sourcefile = self.request.files['projectfile'][0]
            if sourcefile:
                filename = sourcefile['filename']
                if len(filename) > 0:
                    unique = _get_unique_name(self.get_project_dir(),
                                              parse_archive_name(filename))
                    tdir = mkdtemp(prefix=unique)
                    buff = StringIO.StringIO(sourcefile['body'])
                    archive = tarfile.open(fileobj=buff, mode='r:gz')
                    archive.extractall(path=tdir)
                    proj = Project(tdir)
                    project_info = proj.get_info()

                    try:
                        shutil.rmtree(tdir, onerror=onerror)
                    except:
                        pass

                    self.render('projdb/import-metadata-fields.html',
                                projectname=parse_archive_name(unique),
                                description=project_info['description'],
                                version=project_info['version'])
        else:
            # second upload
            forms = {}
            for field in ['projectname', 'description', 'version']:
                if field in self.request.arguments.keys():
                    forms[field] = self.request.arguments[field][0]

            sourcefile = self.request.files['projectfile'][0]
            if sourcefile:
                filename = sourcefile['filename']
                if len(filename) > 0:

                    unique = _get_unique_name(self.get_project_dir(),
                                              parse_archive_name(filename))

                    pdb = Projects()

                    project = {}
                    project['id'] = pdb.predict_next_rowid()
                    project['active'] = 1
                    project['projectname'] = forms['projectname'].strip()
                    project['description'] = forms['description'].strip()
                    project['version'] = forms['version'].strip()
                    project['projpath'] = unique

                    os.mkdir(unique)

                    buff = StringIO.StringIO(sourcefile['body'])

                    archive = tarfile.open(fileobj=buff, mode='r:gz')
                    archive.extractall(path=unique)

                    vcslist = find_vcs()
                    if vcslist:
                        vcs = vcslist[0](unique)
                    else:
                        vcs = DumbRepo(unique)
                    vcs.init_repo()

                    # Update project settings.
                    proj = Project(project['projpath'])
                    dummy = proj.get_info()  # Just to get required keys.
                    info = {}
                    for key in dummy:
                        info[key] = project[key]
                    proj.set_info(info)

                    pdb.new(project)

                    self.redirect("/workspace/project?projpath=" + quote_plus(project['projpath']))

        self.redirect("/")
    def post(self, project_id):

        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]
                
        pdb = Projects()
        
        # Existing project.
        if int(project_id) != pdb.predict_next_rowid():
            project = pdb.get(project_id)
            project_is_new = False
        # New project
        else:
            project = {}
            project['active'] = 0
            project['filename'] = None
            project_is_new = True
        
        if 'projectname' not in forms or \
           len(forms['projectname']) == 0:
            project['projectname'] = "Unnamed Project"
        else:
            project['projectname'] = forms['projectname'].strip()
            
        if 'description' in forms:
            project['description'] = forms['description'].strip()
        else:
            project['description'] =  ''
            
        if 'version' in forms:
            project['version'] = forms['version'].strip()
        else:
            project['version'] =  ''
        
        # if there's no proj file yet, create en empty one
        if not project['filename']:
            
            version = project['version']
            pname = project['projectname']
            
            if len(version):
                filename = '%s-%s' % (pname, version)
            else:
                filename = '%s' % pname
            filename = clean_filename(filename)
            
            unique = '%s.proj' % filename
            i = 1
            while os.path.exists(os.path.join(self.get_project_dir(), \
                                              unique)):
                unique = '%s_%s.proj' % (filename, str(i))
                i = i+1
                
            with open(os.path.join(self.get_project_dir(), unique), 'w') as out:
                out.write('')
                out.close()
                
            project['filename'] = unique
            print 'created file:', pname, unique

        if project_is_new:
            pdb.new(project)
        else:
            for key, value in project.iteritems():
                pdb.set(project_id, key, value)
            pdb.modified(project_id)
        
        self.redirect(self.request.uri)
예제 #13
0
    def post(self, project_id):
        forms = {}
        for field in ['projectname', 'description', 'version']:
            if field in self.request.arguments.keys():
                forms[field] = self.request.arguments[field][0]

        pdb = Projects()

        # Existing project.
        if int(project_id) != pdb.predict_next_rowid():
            project = pdb.get(project_id)
            project_is_new = False
        # New project
        else:
            project = {}
            project['active'] = 0
            project['filename'] = None
            project_is_new = True

        if 'projectname' not in forms or \
           len(forms['projectname']) == 0:
            project['projectname'] = "Unnamed Project"
        else:
            project['projectname'] = forms['projectname'].strip()

        if 'description' in forms:
            project['description'] = forms['description'].strip()
        else:
            project['description'] = ''

        if 'version' in forms:
            project['version'] = forms['version'].strip()
        else:
            project['version'] =''

        # if there's no proj file yet, create en empty one
        if not project['filename']:

            version = project['version']
            pname = project['projectname']

            if len(version):
                filename = '%s-%s' % (pname, version)
            else:
                filename = '%s' % pname
            filename = clean_filename(filename)

            unique = '%s.proj' % filename
            i = 1
            while os.path.exists(os.path.join(self.get_project_dir(), \
                                              unique)):
                unique = '%s_%s.proj' % (filename, str(i))
                i = i+1

            with open(os.path.join(self.get_project_dir(), unique), 'w') as out:
                out.write('')
                out.close()

            project['filename'] = unique

        if project_is_new:
            pdb.new(project)
        else:
            for key, value in project.iteritems():
                pdb.set(project_id, key, value)
            pdb.modified(project_id)

        self.redirect(self.request.uri)
예제 #14
0
    def post(self):
        # The project file is uploaded once to extract the metadata.
        # It is then deleted and the metadata is used to populate another
        # import dialog, giving the user an opportunity to edit the
        # info before importing or cancel the import.
        if not 'projectname' in self.request.arguments:
            # First upload
            sourcefile = self.request.files['projectfile'][0]
            try:
                filename = sourcefile['filename']
                if len(filename) > 0:
                    unique = _get_unique_name(self.get_project_dir(),
                                              parse_archive_name(filename))
                    tdir = mkdtemp(prefix=unique)
                    buff = StringIO.StringIO(sourcefile['body'])
                    archive = tarfile.open(fileobj=buff, mode='r:gz')
                    archive.extractall(path=tdir)
                    proj = Project(tdir)
                    project_info = proj.get_info()

                    try:
                        shutil.rmtree(tdir, onerror=onerror)
                    except:
                        pass

                    self.render('projdb/import-metadata-fields.html',
                                projectname=parse_archive_name(unique),
                                description=project_info['description'],
                                version=project_info['version'])
            except Exception as err:
                print 'ERROR: could not get metadata from', sourcefile
                exc_type, exc_value, exc_traceback = sys.exc_info()
                traceback.print_exception(exc_type, exc_value, exc_traceback)
                self.redirect('/')
        else:
            # second upload
            forms = {}
            for field in ['projectname', 'description', 'version']:
                if field in self.request.arguments.keys():
                    forms[field] = self.request.arguments[field][0]

            sourcefile = self.request.files['projectfile'][0]
            try:
                filename = sourcefile['filename']
                if len(filename) > 0:

                    unique = _get_unique_name(self.get_project_dir(),
                                              parse_archive_name(filename))

                    pdb = Projects()

                    project = {}
                    project['id'] = pdb.predict_next_rowid()
                    project['active'] = 1
                    project['projectname'] = forms['projectname'].strip()
                    project['description'] = forms['description'].strip()
                    project['version'] = forms['version'].strip()
                    project['projpath'] = unique

                    os.mkdir(unique)

                    buff = StringIO.StringIO(sourcefile['body'])

                    archive = tarfile.open(fileobj=buff, mode='r:gz')
                    archive.extractall(path=unique)

                    vcslist = find_vcs()
                    if vcslist:
                        vcs = vcslist[0](unique)
                    else:
                        vcs = DumbRepo(unique)
                    vcs.init_repo()

                    # Update project settings.
                    proj = Project(project['projpath'])
                    dummy = proj.get_info()  # Just to get required keys.
                    info = {}
                    for key in dummy:
                        info[key] = project[key]
                    proj.set_info(info)

                    pdb.new(project)

                    self.redirect("/workspace/project?projpath=" +
                                  quote_plus(project['projpath']))
            except Exception as err:
                print 'ERROR: could not get import project from', sourcefile
                exc_type, exc_value, exc_traceback = sys.exc_info()
                traceback.print_exception(exc_type, exc_value, exc_traceback)
                self.redirect('/')