Пример #1
0
def sync_all(guid, db_user, db_password, db_name):
    session = db.Session()
    projects = remote.get_projects(guid)
    LOGGER.info('Scanning %d projects', len(projects))
    for project in projects:
        LOGGER.info("Scanning project %d", project.id)
        for user in project.members:
            db_user = _to_orm(user, types.User)
            db_user = session.merge(db_user)
        for label in project.labels:
            db_label = types.Label()
            db_label.name = label
            db_label = session.merge(db_label)
        db_project = _to_orm(project, types.Project, {
            'labels': [],
            'members': []
        })
        db_project = session.merge(db_project)

        member_names = [m.name for m in project.members]
        db_project.members = list(
            session.query(types.User).filter(
                types.User.name.in_(member_names)))

        db_project.labels = list(
            session.query(types.Label).filter(
                types.Label.name.in_(project.labels)))

        session.commit()
    for project in projects:
        _sync_stories(guid, project, session)
    session.commit()
Пример #2
0
def sync_all(guid, db_user, db_password, db_name):
    session = db.Session()
    projects = remote.get_projects(guid)
    LOGGER.info('Scanning %d projects', len(projects))
    for project in projects:
        LOGGER.info("Scanning project %d", project.id)
        for user in project.members:
            db_user = _to_orm(user, types.User)
            db_user = session.merge(db_user)
        for label in project.labels:
            db_label = types.Label()
            db_label.name = label
            db_label = session.merge(db_label)
        db_project = _to_orm(project, types.Project, {'labels':[], 'members':[]})
        db_project = session.merge(db_project)
    
        member_names = [m.name for m in project.members] 
        db_project.members = list(session.query(types.User).filter(types.User.name.in_(member_names)))
        
        db_project.labels = list(session.query(types.Label).filter(types.Label.name.in_(project.labels)))

        session.commit()
    for project in projects:
        _sync_stories(guid, project, session)
    session.commit()
Пример #3
0
def projects(guid):
    projects = remote.get_projects(guid)
    for project in projects:
        print("Project {0}: {1}".format(project.name, project.id))