Пример #1
0
 def _post_install():
     wf = open('open-cravat-install-log.txt', 'w')
     try:
         from cravat import constants as c
         def find_cravat_path():
             for p in sys.path:
                 if os.path.isdir(p) and 'site-packages' in p and 'cravat' in os.listdir(p):
                     return os.path.join(p, 'cravat')
         install_path = find_cravat_path()
         system_conf_path = os.path.join(install_path,
                                         c.system_conf_fname)
         system_template_conf_path = c.system_conf_template_path
         if self.modules_dir == None:
             default_modules_dir = os.path.join(
                 install_path, c.default_modules_dir_relative)
         else:
             default_modules_dir = self.modules_dir
         if not(os.path.exists(c.system_conf_path)):
             shutil.copy(system_template_conf_path,
                         system_conf_path)
         else:
             shutil.copy(c.system_conf_path, system_conf_path)
         from cravat import admin_util as au
         au.set_modules_dir(default_modules_dir)
     except:
         import traceback
         wf.write(traceback.format_exc() + '\n')
     wf.write('done\n')
     wf.close()
Пример #2
0
 def _post_install():
     f = open('d:\\log.txt', 'w')
     from cravat import constants as c
     def find_cravat_path():
         for p in sys.path:
             if os.path.isdir(p) and 'cravat' in os.listdir(p):
                 return os.path.join(p, 'cravat')
     install_path = find_cravat_path()
     f.write('install path=' + install_path + '\n')
     system_conf_path = os.path.join(install_path,
                                     c.system_conf_fname)
     f.write('system_conf_path=' + system_conf_path + '\n')
     system_template_conf_path = c.system_conf_template_path
     f.write('system_template_conf_path=' + system_template_conf_path)
     if self.modules_dir == None:
         default_modules_dir = os.path.join(
             install_path, c.default_modules_dir_relative)
     else:
         default_modules_dir = self.modules_dir
     f.write('default_modules_dir=' + default_modules_dir + '\n')
     from cravat import admin_util as au
     au.set_modules_dir(default_modules_dir)
     if not(os.path.exists(c.system_conf_path)):
         
         shutil.copy(system_template_conf_path,
                     system_conf_path)
     else:
         shutil.copy(c.system_conf_path, system_conf_path)
     f.close()
Пример #3
0
async def update_system_conf(request):
    queries = request.rel_url.query
    sysconf = json.loads(queries['sysconf'])
    try:
        success = au.update_system_conf_file(sysconf)
        if 'modules_dir' in sysconf:
            modules_dir = sysconf['modules_dir']
            cravat_yml_path = os.path.join(modules_dir, 'cravat.yml')
            if os.path.exists(cravat_yml_path) == False:
                au.set_modules_dir(modules_dir)
    except:
        raise
        sysconf = {}
        success = False
    return web.json_response({'success': success, 'sysconf': sysconf})
Пример #4
0
async def update_system_conf(request):
    global servermode
    if servermode and server_ready:
        username = await cravat_multiuser.get_username(request)
        if username != 'admin':
            return web.json_response({
                'success':
                False,
                'msg':
                'Only admin can change the settings.'
            })
        r = await cravat_multiuser.is_loggedin(request)
        if r == False:
            return web.json_response({
                'success':
                False,
                'mgs':
                'Only logged-in admin can change the settings.'
            })
    queries = request.rel_url.query
    sysconf = json.loads(queries['sysconf'])
    try:
        success = au.update_system_conf_file(sysconf)
        if 'modules_dir' in sysconf:
            modules_dir = sysconf['modules_dir']
            cravat_yml_path = os.path.join(modules_dir, 'cravat.yml')
            if os.path.exists(cravat_yml_path) == False:
                au.set_modules_dir(modules_dir)
        global job_queue
        qitem = {
            'cmd': 'set_max_num_concurrent_jobs',
            'max_num_concurrent_jobs': sysconf['max_num_concurrent_jobs']
        }
        job_queue.put(qitem)
    except:
        raise
        sysconf = {}
        success = False
    return web.json_response({'success': success, 'sysconf': sysconf})
Пример #5
0
 def set_modules_dir(args):
     if args.directory:
         au.set_modules_dir(args.directory)
     print(au.get_modules_dir())