def refreshProject ( self, serveradress ): """If server exist set 'ok' icon """ self.server = False if utils.serverExists ( serveradress ) : icon = os.path.join ( utils.getCCPath (), "ok.png" ) self.server = utils.getServer ( serveradress ) """Clear current comboBox_project list""" self.comboBox_project.clear () icon = os.path.join ( utils.getCCPath (), "cross.png" ) self.projects = ["No project available"] if utils.serverExists ( serveradress ) : projects = core.lsProjectServer ( serveradress ) if len ( projects ) > 0 : self.projects = projects self.comboBox_project.addItems ( self.projects ) root = self.lineEdit_root.text() root = os.path.join ( root, "projects" ) for i in range ( 0, self.comboBox_project.count () ): proj = self.comboBox_project.itemText ( i ) curroot = os.path.join ( root, proj ) if proj == "No project available" or os.path.exists ( curroot ) : icon = os.path.join ( utils.getCCPath (), "cross.png" ) self.project_stat [ proj ] = False else: icon = os.path.join ( utils.getCCPath (), "ok.png" ) self.project_stat [ proj ] = True self.comboBox_project.setItemIcon ( i, QtGui.QIcon ( icon ) ) self.pushButton.setEnabled ( self.project_stat [ self.comboBox_project.currentText () ] )
def createProject (name = "", description = "Default", db_server = "", host_root = "", overdoc = dict (), badassversion = None): """ This function create a project. :param name: The project name :type name: str :param description: The project description :type description: str :param db_server: The data base adress :type db_server: str :param host_root: The host data server root adress :type host_root: str :param overdoc: A dictionnary that contains extra document attributes. :type overdoc: dict :returns: couchdb.client.Database -- return the db. :raises: AttributeError, KeyError **Example:** >>> createProject ( name = "prod", description = "this is the project prod", db_server = "admin:[email protected]:5984", host_root = "[email protected]:/homeworks" ) """ # Check if DB server exists adress="http://%s/"%db_server exists=utils.serverExists (adress) if not exists : print "createProject(): Wrong DB server adress,user or/and password" return False # Check args if name=="" : print "CreateProject(): Please provide a project name" return False if db_server=="" or db_server==None : print "CreateProject(): No server adress provided" return False # Check if DB and project already exist db=utils.getDb(name, adress) # If DB and project exists return if db!=False : return False # Create DB db=utils.createDb(name, adress) # Create project env and cred file createProjectEnv(name, badassversion) createProjectCred(name, db_server, host_root) # Adding db project documents assets=utils.getAssetTypes() tasks=utils.getAssetTasks() # Users users=dict() users[utils.getCurrentUser()]="admin" doc={ "_id" : "%s"%name, "type" : "project", "name" : name, "description" : description, "asset_types" : assets, "asset_tasks" : tasks, "creator" : os.getenv ("USER"), "created" : time.time(), "root" : "/homeworks", "users" : users, "status": {"art":"ns", "tech":"ns"}, "host" : host_root } doc.update(overdoc) _id, _rev=db.save(doc) print "createProject(): Project '%s' created"%(name) return db