Esempio n. 1
0
def change_status(target_repo, state):
    from models import Repo
#     class Repo(Document):
#         url = StringField(max_length=100,default='Not set yet')
#         last_used = DateTimeField(default=datetime.now())
#         created_on = DateTimeField(default=datetime.now())
#         monitoring = StringField(max_length=100,default='Not set yet')
#         state = StringField(max_length=50,default='Ready')
#         owner = StringField(max_length=50,default='no')
    
    
    if not use_database:
        return ''
    try:
        repo = Repo.objects.get(url=target_repo)
        repo.last_used = datetime.today()
        repo.state = state
        repo.owner = parent_folder
        repo.save()
    except DoesNotExist:
        repo = Repo()
        repo.url=target_repo
        repo.state = state
        repo.owner = parent_folder
        repo.save()
    except Exception as e:
        print 'database_exception: '+str(e)
Esempio n. 2
0
def RunWithPars(pars, uid):
    startTime = Common.getCurrentTimeMil()
    reposFol = 'SavePath/Repos/'
    if not os.path.exists(config.basedir + '/' + reposFol):
        os.makedirs(config.basedir + '/' + reposFol)
    fname = reposFol + Common.gen_rnd_filename()
    os.makedirs(config.basedir + '/' + fname)
    ##ADD Field
    e = Repo()
    e.cloneFinishDate = "--RUNNING--"
    e.cloneStartDate = str(startTime)
    e.repoInfo = ''
    e.isPrivate = int(pars['isPrivate'])
    e.path = fname
    e.repoName = pars['repoName']
    e.url = pars['url']
    e.userId = uid
    db.session.add(e)
    db.session.commit()

    try:
        porcelain.clone(pars['url'], config.basedir + '/' + fname)
        endTime = Common.getCurrentTimeMil()
        e.cloneFinishDate = str(endTime)
        db.session.commit()

    except Exception as ex:
        print(ex)
        e.delete()
        db.session.commit()
Esempio n. 3
0
def change_status(target_repo, state):
    from models import Repo
    if not use_database:
        return ''
    try:
        repo = Repo.objects.get(url=target_repo)
        repo.last_used = datetime.today()
        repo.state = state
        repo.owner = parent_folder
        repo.save()
    except DoesNotExist:
        repo = Repo()
        repo.url = target_repo
        repo.state = state
        repo.owner = parent_folder
        repo.save()
    except Exception as e:
        print 'database_exception: ' + str(e)
Esempio n. 4
0
def change_status(target_repo, state):
    from models import Repo
    if not use_database:
        return ''
    try:
        repo = Repo.objects.get(url=target_repo)
        repo.last_used = datetime.today()
        repo.state = state
        repo.owner = parent_folder
        repo.save()
    except DoesNotExist:
        repo = Repo()
        repo.url = target_repo
        repo.state = state
        repo.owner = parent_folder
        repo.save()
    except Exception as e:
        print 'database_exception: ' + str(e)