Skip to content

Commit

Permalink
Couple of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Dec 11, 2018
1 parent dbb3e4e commit 48551ef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
5 changes: 2 additions & 3 deletions cvat/apps/git/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.1.3 on 2018-12-04 10:09
# Generated by Django 2.1.3 on 2018-12-05 11:10

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -20,8 +20,7 @@ class Migration(migrations.Migration):
('url', models.URLField(max_length=2000)),
('path', models.CharField(max_length=256)),
('sync_date', models.DateTimeField(auto_now_add=True)),
('check_date', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(max_length=20)),
('status', models.CharField(default='!sync', max_length=20)),
],
),
]
3 changes: 1 addition & 2 deletions cvat/apps/git/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ class GitData(models.Model):
url = models.URLField(max_length = 2000)
path = models.CharField(max_length=256)
sync_date = models.DateTimeField(auto_now_add=True)
check_date = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=20)
status = models.CharField(max_length=20, default="!sync")
6 changes: 1 addition & 5 deletions cvat/apps/git/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,9 @@ def get_repository(request, tid):
def get_meta_info(request):
try:
db_git_records = GitData.objects.all()
cur_date = timezone.now()
response = {}
for db_git in db_git_records:
if (cur_date - db_git.check_date).seconds > 600 or not len(db_git.status):
response[db_git.task_id] = CVATGit.get(db_git.task_id, request.user)
else:
response[db_git.task_id] = db_git.status
response[db_git.task_id] = db_git.status

return JsonResponse(response, safe = False)
except Exception as ex:
Expand Down
5 changes: 2 additions & 3 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ def generate_ssh_keys():

try:
with FileLock(pidfile):
subprocess.run(['ssh-add', '{}/*'.format(ssh_dir)])
subprocess.run(['ssh-add', '{}/*'.format(ssh_dir)], shell = True, stderr = subprocess.PIPE)
keys = subprocess.run(['ssh-add -l'], shell = True,
stdout = subprocess.PIPE).stdout.decode('utf-8').split('\n')

if 'has no identities' in keys[0]:
print('SSH keys were not found')
keys = os.listdir(keys_dir)
Expand All @@ -66,7 +65,7 @@ def generate_ssh_keys():
shutil.copymode('{}/id_rsa'.format(keys_dir), '{}/id_rsa'.format(ssh_dir))
shutil.copyfile('{}/id_rsa.pub'.format(keys_dir), '{}/id_rsa.pub'.format(ssh_dir))
shutil.copymode('{}/id_rsa.pub'.format(keys_dir), '{}/id_rsa.pub'.format(ssh_dir))
subprocess.run(['ssh-add', '{}/id_rsa'.format(ssh_dir)])
subprocess.run(['ssh-add', '{}/id_rsa'.format(ssh_dir)], shell = True)
os.remove(pidfile)
except:
return
Expand Down

0 comments on commit 48551ef

Please sign in to comment.