Ejemplo n.º 1
0
def do_init():
    create_all()
    project1 = model.session.query(RowProject).first()
    if project1 is None:
        print "No projects found. Creating a 'llampex' project"
        project1 = RowProject()
        project1.code = "llampex"
        project1.description = "Llampex main project"
        project1.db = "llampex"
        project1.path = os.path.realpath(filedir("../"))
        project1.active = True
        model.session.add(project1)
        model.session.commit()
        
    user1 = model.session.query(RowUser).first()
    if user1 is None:
        print "No users found. Creating a 'llampex' user with password 'llampex'"
        user1 = RowUser()
        user1.username = "******"
        user1.password = compute_password("llampex")
        model.session.add(user1)
        model.session.commit()
        for project in model.session.query(RowProject):
            nn = RowProjectUser()
            nn.user = user1
            nn.project = project
            model.session.add(nn)
            
            user1.projects.append(nn)
        model.session.commit()
Ejemplo n.º 2
0
def do_addproject(code = None, description = None, db = None, path = None, host = None, port = None, user = None, password = None, active = None):
    if code is None:
        code = raw_input("Please give a code: ")
    if not code: return
    if model.session.query(RowProject).filter(RowProject.code == code).first():
        print "This project already exists. Giving up."
        return
    if description is None:
        description = raw_input("Please give a description: ")
    if db is None:
        db = raw_input("Please give a database: ")
    if not db: return
    if path is None:
        path = raw_input("Please give a path: ")
    if not path: return
    if host is None:
        host = raw_input("Please give a host: ")
    if not host: host = "127.0.0.1" # default is localhost
    if port is None:
        port = raw_input("Please give a port: ")
    if not port: port = "5432" # default is 5432
    if user is None:
        user = raw_input("Please give a user: "******"llampexuser" # default
    if password is None:
        password = raw_input("Please give a password: "******"llampexpasswd" # default
    if active is None:
        active = raw_input("Project is actived? [True|False]: ")
    if active != "False":
        active = "True" # default is true
        
    project1 = RowProject()
    project1.code = code
    project1.description = description
    project1.db = db
    project1.path = path
    project1.host = host
    project1.port = port
    project1.user = user
    project1.password = password
    project1.active = active
    
    model.session.add(project1)
    model.session.commit()
    print "Project %s added." % (repr(project1.code))
Ejemplo n.º 3
0
 def newProject(self, code, desc, db, path, host, port, user, password, encrypt, active):
     project = RowProject()
     project.code = code
     project.description = desc
     project.db = db
     project.path = path
     project.host = None if (host == "") else host
     project.port = None if (port == "") else port
     project.user = None if (user == "") else user
     project.active = active
     
     #TODO: Implementate Encryption
     if encrypt == "None":
         project.password = None if (password == "") else password
         project.passwdcipher = None
         
     model.session.add(project)
     return self.do_Commit()
Ejemplo n.º 4
0
    def newProject(self, code, desc, db, path, host, port, user, password,
                   encrypt, active):
        project = RowProject()
        project.code = code
        project.description = desc
        project.db = db
        project.path = path
        project.host = None if (host == "") else host
        project.port = None if (port == "") else port
        project.user = None if (user == "") else user
        project.active = active

        #TODO: Implementate Encryption
        if encrypt == "None":
            project.password = None if (password == "") else password
            project.passwdcipher = None

        model.session.add(project)
        return self.do_Commit()