Example #1
0
def cmd_init(settings):
    sa = Workspace.get_session('project', __version__)
    sa = Project.get_session('default', settings.dbref)
    #sa = get_session(settings.dbref)
    pwd = os.getcwd()
    name = os.path.basename(pwd)
    projdir = Workdir.find(pwd)
    rs = Project.search(name=name)
    if projdir:
        if not rs:
        	pass
        print("Already in existing project!")
        print(projdir[0])
        return 1
    if rs:
        print("Project with this name already exists")
        return 1
    projdir = Workdir(pwd)
    project = Project(
            name=name,
            date_added=datetime.now(),
        )
    curhost = Host.init(sa=sa) # FIXME returns localhost.
    # TODO project.hosts.append(curhost)
    repo = Repo(pwd)
    checkout = VersionControl(vc_type=repo.rtype, path=pwd, host=curhost)
    sa.add(checkout)
    project.repositories.append( checkout )# TODO: and remotes
    sa.add(project)
    sa.commit()
    projdir.init(create=True)
    print("Created project", name, projdir.metadir_id)
Example #2
0
def cmd_info(settings):
    sa = Project.get_session('default', settings.dbref)
    #sa = get_session(settings.dbref)
    pwd = os.getcwd()
    name = os.path.basename(pwd)
    workdir = Workdir.find(pwd)
    if not workdir:
        print("Not in a metadata workdir!")
    rs = Project.search(_sa=sa, name=name)
    if not rs:
        print("No project found for %r" % name)
        return 1
    proj=rs[0]
    try:
        hosts = proj.hosts
    except Exception as e:
        print(settings.dbref, Project.metadata.bind)
        log.std("Error proj.hosts %s", e)
        hosts = []
    print(proj.name, hosts, proj.repositories[0].vc_type, proj.date_added)
Example #3
0
def cmd_list(settings):
    sa = Project.get_session('default', settings.dbref)
    for p in sa.query(Project).all():
        print(p)