summaryrefslogtreecommitdiff
path: root/kpov_judge/add_assignment.py
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge/add_assignment.py')
-rwxr-xr-xkpov_judge/add_assignment.py54
1 files changed, 0 insertions, 54 deletions
diff --git a/kpov_judge/add_assignment.py b/kpov_judge/add_assignment.py
deleted file mode 100755
index 2453eeb..0000000
--- a/kpov_judge/add_assignment.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import pymongo
-from bson.son import SON
-import sys
-import inspect
-import kpov_random_helpers
-import settings
-import guestfs
-import glob
-
-if __name__ == '__main__':
- if len(sys.argv) != 3:
- print "Usage: {0} task_name task_source.py"
- print "The task_source should contain two functions - task(param1, param2, ...) and task_check(res, params)"
- task_id = sys.argv[1]
- fname = sys.argv[2]
- db = pymongo.Connection(settings.DB_HOST).kpov
- try:
- db.authenticate(settings.USERNAME, settings.PASSWORD)
- except Exception, e:
- print "Not authenticated:"+str(e)
- #no auth or auth config?
- source = open(fname).read()
- code = compile(source, fname, 'exec')
- # the following line creates:
- # task, task_check, gen_params, prepare_disks, computers, params_meta.
- exec(code)
- task_source = inspect.getsource(task)
- task_check_source = inspect.getsource(task_check)
- gen_params_source = inspect.getsource(gen_params)
- prepare_disks_source = inspect.getsource(prepare_disks)
- x = params_meta.keys() # check for existence
- db.computers_meta.remove({'task_id': task_id})
- auto_networks = set([None])
- for k, v in computers.iteritems():
- for n in v.get('networks_interfaces', []):
- auto_networks.add(n.get('network', None))
- db.computers_meta.update({'task_id': task_id, 'name': k}, {'$set': v}, upsert=True)
- auto_networks.remove(None)
- db.networks.remove({'task_id': task_id})
- try:
- net_list = networks.iteritems()
- except:
- net_list = [(k, {'public': False}) for k in auto_networks]
- for k, v in net_list:
- db.networks.update({'task_id': task_id, 'name': k}, {'$set': v}, upsert=True)
- db.task_checkers.update({'task_id': task_id}, {'$set': {'source': task_check_source}}, upsert=True)
- db.tasks.update({'task_id': task_id},{'$set': {'source': task_source}}, upsert=True)
- db.prepare_disks.update({'task_id': task_id}, {'$set': {'source': prepare_disks_source}}, upsert=True)
- db.gen_params.update({'task_id': task_id}, {'$set': {'source': gen_params_source}}, upsert=True)
- db.task_params_meta.update({'task_id': task_id}, {'$set': {'params': params_meta}}, upsert=True)
-