示例#1
0
def test_use_config_section():
    output = StringIO()
    python3(path2main, program_output, u='TEST',
            config=config_file, _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#2
0
def sync():
    """ Syncs all repos
    """
    # Try auto-merge; if conflict: update_readme.py && git add README.md && git commit.  If that fails, too, then it was a JSON conflict that will have to be handled manually.

    print("Syncing repos...\n")
    for downstream, upstream in repos:
        downstream = f"https://{new_env['CDKBOT_GH']}@github.com/{downstream}"
        sys.stdout.write(f"\t{upstream} -> {downstream}\n")
        identifier = str(uuid.uuid4())
        os.makedirs(identifier)
        for line in sh.git.clone(downstream, identifier, _iter=True):
            print(line)
        sh.git.config("user.email", '*****@*****.**', _cwd=identifier)
        sh.git.config("user.name", 'cdkbot', _cwd=identifier)
        sh.git.config("--global", "push.default", "simple")
        sh.git.remote("add", "upstream", upstream, _cwd=identifier)
        for line in sh.git.fetch("upstream", _cwd=identifier, _iter=True):
            print(line)
        sh.git.checkout("master", _cwd=identifier)
        if 'layer-index' in downstream:
            sh.python3('update_readme.py', _cwd=identifier)
        for line in sh.git.merge("upstream/master",
                                 _cwd=identifier,
                                 _iter=True):
            print(line)
        for line in sh.git.push("origin", _cwd=identifier, _iter=True):
            print(line)
示例#3
0
def test_basic_filter_config():
    "Filter the file according to the config file."
    output = StringIO()
    python3(path2main, 'test/program_output_config', config=config_file, _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
def hostPingTest(args):
    try:
        # 3대의 호스트에 ping 테스트
        ret_val = []
        ret_text = ""
        for host in args.host_names:
            item = {}
            ping_check = os.system("ping -c 1 -W 1 " + host + " > /dev/null")
            if ping_check == 0:
                item["host"] = host
                item["status"] = 'up'

            else:
                item["host"] = host
                item["status"] = 'down'
                ret_text += host + "와 네트워크 테스트 실패하였습니다\n"

            ret_val.append(item)

        # ex : ssh root@host echo 명령을 수행시 인증이 되어있으면 바로 응답이 오는데 인증이 되어있지 않으면 정상응답이 오지 않음
        # 핑거프린트 해결을 위해 ssh-scan.py 호출
        python3(pluginpath + '/python/host/ssh-scan.py')

        if ret_text == "":
            return createReturn(code=200, val="host ping test success")
        else:
            return createReturn(code=500, val=ret_text)

    except Exception as e:
        # 결과값 리턴
        print(e)
        return createReturn(code=500, val={})
示例#5
0
def test_basic_filter_pipe():
    output = StringIO()
    python3(cat(program_output), path2main,
            start_pattern=start_pattern,
            error_pattern=error_pattern,
            _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#6
0
def test_mail_empty_mail_group():
    output = StringIO()
    python3(path2main,
            'test/program_output_mail_empty_group',
            config=config_file,
            _err=output)

    correctly_filtered_output = ''
    assert correctly_filtered_output == output.getvalue()
示例#7
0
 def __init__(self, inpath, venv):
     self.inpath = inpath
     self.venv = venv
     sh.python3('-m', 'venv', '--clear', '--copies', self.venv)
     self.python = sh.Command(os.path.join(self.venv, "bin", "python3"))
     self.pip = sh.Command(os.path.join(self.venv, "bin", "pip"))
     self.pip("install", "-I", "cython==0.24")
     self.pip('install', 'wheel')
     self.cython = sh.Command(os.path.join(self.venv, "bin", "cython"))
示例#8
0
def _sync_upstream(layer_list, dry_run):
    """ Syncs any of the forked upstream repos

    layer_list: YAML spec containing git repos and their upstream/downstream properties
    """
    layer_list = yaml.safe_load(Path(layer_list).read_text(encoding="utf8"))
    new_env = os.environ.copy()

    for layer_map in layer_list:
        for layer_name, repos in layer_map.items():
            upstream = repos["upstream"]
            downstream = repos["downstream"]
            if urlparse(upstream).path.lstrip("/") == downstream:
                click.echo(
                    f"Skipping {layer_name} :: {upstream} == {downstream}")
                continue
            click.echo(
                f"Syncing {layer_name} :: {repos['upstream']} -> {repos['downstream']}"
            )
            if not dry_run:
                downstream = f"https://{new_env['CDKBOT_GH_USR']}:{new_env['CDKBOT_GH_PSW']}@github.com/{downstream}"
                identifier = str(uuid.uuid4())
                os.makedirs(identifier)
                try:
                    for line in sh.git.clone(downstream,
                                             identifier,
                                             _iter=True,
                                             _bg_exc=False):
                        click.echo(line)
                except sh.ErrorReturnCode as e:
                    click.echo(f"Failed to clone repo: {e.stderr.decode()}")
                    sys.exit(1)
                sh.git.config("user.email",
                              "*****@*****.**",
                              _cwd=identifier)
                sh.git.config("user.name", "cdkbot", _cwd=identifier)
                sh.git.config("--global", "push.default", "simple")
                sh.git.remote("add", "upstream", upstream, _cwd=identifier)
                for line in sh.git.fetch("upstream",
                                         _cwd=identifier,
                                         _iter=True,
                                         _bg_exc=False):
                    click.echo(line)
                sh.git.checkout("master", _cwd=identifier)
                if "layer-index" in downstream:
                    sh.python3("update_readme.py", _cwd=identifier)
                for line in sh.git.merge("upstream/master",
                                         _cwd=identifier,
                                         _iter=True,
                                         _bg_exc=False):
                    click.echo(line)
                for line in sh.git.push("origin",
                                        _cwd=identifier,
                                        _iter=True,
                                        _bg_exc=True):
                    click.echo(line)
示例#9
0
def test_basic_filter_pipe():
    output = StringIO()
    python3(cat(program_output),
            path2main,
            start_pattern=start_pattern,
            error_pattern=error_pattern,
            _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#10
0
def test_mail():
    output = StringIO()
    python3(path2main,
            'test/program_output_mail',
            config=config_file,
            _err=output)

    with open('test/program_output_filtered_mail',
              'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#11
0
def test_use_config_section():
    output = StringIO()
    python3(path2main,
            program_output,
            u='TEST',
            config=config_file,
            _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#12
0
def test_basic_filter_config():
    "Filter the file according to the config file."
    output = StringIO()
    python3(path2main,
            'test/program_output_config',
            config=config_file,
            _out=output)

    with open(program_output_filtered, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
def resetCloudCenter(args):

    success_bool = True

    #=========== pcs cluster 초기화 ===========
    # 리소스 삭제
    result = json.loads(
        python3(pluginpath + '/python/pcs/main.py', 'remove', '--resource',
                'cloudcenter_res').stdout.decode())
    if result['code'] not in [200, 400]:
        success_bool = False

    # 클러스터 삭제
    result = json.loads(
        python3(pluginpath + '/python/pcs/main.py', 'destroy').stdout.decode())
    if result['code'] not in [200, 400]:
        success_bool = False

    # ceph rbd 이미지 삭제
    result = os.system("rbd ls -p rbd | grep ccvm > /dev/null")
    if result == 0:
        os.system("rbd rm rbd/ccvm")

    # virsh 초기화
    os.system("virsh destroy ccvm > /dev/null")
    os.system("virsh undefine ccvm > /dev/null")

    # 작업폴더 생성
    os.system("mkdir -p " + pluginpath + "/tools/vmconfig/ccvm")
    '''
    # cloudinit iso 삭제
    os.system("rm -f "+pluginpath+"/tools/vmconfig/ccvm/ccvm-cloudinit.iso")
    
    # vm xml 템플릿 삭제
    os.system("rm -f "+pluginpath+"/tools/vmconfig/ccvm/ccvm.xml")
    
    # cloudinit iso에 사용할 hosts 삭제
    os.system("rm -f "+pluginpath+"/tools/vmconfig/ccvm/hosts")

    # cloudinit iso에 사용할 개인키 : id_rsa 삭제
    os.system("rm -f "+pluginpath+"/tools/vmconfig/ccvm/id_rsa")

    # cloudinit iso에 사용할 공개키 : id_rsa.pub 삭제
    os.system("rm -f "+pluginpath+"/tools/vmconfig/ccvm/id_rsa.pub")
    '''

    # 확인후 폴더 밑 내용 다 삭제해도 무관하면 아래 코드 수행
    os.system("rm -rf " + pluginpath + "/tools/vmconfig/ccvm/*")

    # 결과값 리턴
    if success_bool:
        return createReturn(code=200, val="cloud center reset success")
    else:
        return createReturn(code=500, val="cloud center reset fail")
示例#14
0
def compile_cython():
    '''Compile Cython modules using sh'''
    print('\n-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-')
    print('Compiling Cython code...')
    # compile inpyranoid
    from sh import python3
    shOut = python3('compile_inpyranoid_c.py', 'build_ext', '--inplace')
    print(shOut)
    # compile mmseqs_parser
    shOut = python3('compile_mmseqs_parser_c.py', 'build_ext', '--inplace')
    print(shOut)
示例#15
0
def pcsStop():
    try:
        ret = sh.python3(pluginpath + "/python/pcs/main.py","disable", "--resource", "cloudcenter_res").stdout.decode()
        while True:
            retPcsStatusJson = json.loads(sh.python3(pluginpath + "/python/pcs/main.py","status", "--resource", "cloudcenter_res").stdout.decode())
            if retPcsStatusJson['val']['role'] == 'Stopped':
                break
    except Exception as e:
        ret = createReturn(code=500, val='ERROR')
        print ('EXCEPTION : ',e)
    
    return ret
def import_data(json_name, package_dir):

    json_path = os.path.join(get_json_dir(), json_name)
    if os.path.exists(json_path):
        print('loading %s' % json_name)
        sh.cd(package_dir)
        if IS_PY2:
            sh.python('manage.py', 'loaddata', json_path)
        else:
            sh.python3('manage.py', 'loaddata', json_path)
    else:
        log('%s does not exist' % json_path)
def setupPcsCluster(args):
    
    success_bool = True
    
    #=========== pcs cluster 구성 ===========
    # ceph 이미지 등록
    os.system("qemu-img convert -f qcow2 -O rbd /var/lib/libvirt/images/ablestack-template-back.qcow2 rbd:rbd/ccvm")
    # ccvm image resize
    os.system("rbd resize -s 500G ccvm")

    # 클러스터 구성
    result = json.loads(python3(pluginpath + '/python/pcs/main.py', 'config', '--cluster', 'cloudcenter_cluster', '--hosts', args.host_names[0], args.host_names[1], args.host_names[2] ).stdout.decode())
    if result['code'] not in [200]:
        success_bool = False

    # 리소스 생성
    result = json.loads(python3(pluginpath+'/python/pcs/main.py', 'create', '--resource', 'cloudcenter_res', '--xml', pluginpath+'/tools/vmconfig/ccvm/ccvm.xml' ).stdout.decode())
    if result['code'] not in [200]:
        success_bool = False

    #ccvm이 정상적으로 생성 되었는지 확인
    domid_check = ""
    cnt_num = 0
    while True:
        time.sleep(1)
        cnt_num += 1
        domid_check = os.system("virsh domid ccvm > /dev/null")
        if domid_check == 0 or cnt_num > 300:
            break

    # psc 구성한 3대의 호스트 crontab에 ccvm 스냅샷 기능 추가
    for host in args.host_names:
        os.system("ssh root@"+host+" \"rm -f /var/spool/cron/tmpfile\"")
        
        # /var/spool/cron/root 파일이 존재하면 실행 (file_exist 값이 0 이면 존재)
        file_exist = os.system("ssh root@"+host+" \"ls /var/spool/cron |grep root > /dev/null\"")
        if file_exist == 0 :
            os.system("ssh root@"+host+" \"awk '!/create_ccvm_snap.py/' /var/spool/cron/root > /var/spool/cron/tmpfile && mv -f /var/spool/cron/tmpfile /var/spool/cron/root\"")

        # crontab에 등록
        os.system("ssh root@"+host+" \"echo -e \'0 1 * * * /usr/bin/python3 /usr/share/cockpit/ablestack/python/ccvm_snap/create_ccvm_snap.py\' >> /var/spool/cron/root | chmod 600 /var/spool/cron/root\"")
        # crond 재시작
        os.system("ssh root@"+host+" \"systemctl restart crond.service\"")

    if domid_check != 0:
        success_bool = False

    # 결과값 리턴
    if success_bool:
        return createReturn(code=200, val="cloud center setup success")
    else:
        return createReturn(code=500, val="cloud center setup fail")
示例#18
0
def pcsMigration():
    try:
        ret = sh.python3(pluginpath + "/python/pcs/main.py","move", "--resource", "cloudcenter_res", "--target",  args.target).stdout.decode()
        while True:
            retPcsStatusJson = json.loads(sh.python3(pluginpath + "/python/pcs/main.py","status", "--resource", "cloudcenter_res").stdout.decode())
            if retPcsStatusJson['val']['role'] == 'Started':
                break
        sh.python3(pluginpath + "/python/pcs/main.py","cleanup", "--resource", "cloudcenter_res").stdout.decode()
    except Exception as e:
        ret = createReturn(code=500, val='ERROR')
        print ('EXCEPTION : ',e)
    
    return ret 
示例#19
0
def test_filter_empty_group():
    file = 'test/program_output_empty_group'
    filtered_output_file = 'test/program_output_filtered_empty_group'
    # Test with the file passed as a parameter.
    output = StringIO()
    python3(path2main, file,
            start_pattern=start_pattern,
            error_pattern=error_pattern,
            start_group='#### (?P<command>.+) - (?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2})',
            end_group='#### END',
            mail_to='*****@*****.**',
            _out=output)

    with open(filtered_output_file, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#20
0
def createScvmCloudinit(args):
    
    success_bool = True
    
    # cloudinit iso에 사용할 hosts 파일 생성
    cmd = "cat > "+args.file1+"<< EOF\n"
    cmd += args.text1
    cmd += "\nEOF"
    os.system(cmd)

    # cloudinit iso에 사용할 개인키 : id_rsa 파일 생성
    cmd = "cat > "+args.file2+"<< EOF\n"
    cmd += args.text2
    cmd += "\nEOF"
    os.system(cmd)

    # cloudinit iso에 사용할 공개키 : id_rsa.pub 생성
    cmd = "cat > "+args.file3+"<< EOF\n"
    cmd += args.text3
    cmd += "\nEOF"
    os.system(cmd)

    # cloudinit iso 생성 (/usr/share/cockpit/ablestack/tools/vmconfig/scvm/scvm-cloudinit.iso)
    result = json.loads(python3(pluginpath + '/tools/cloudinit/gencloudinit.py','--hostname',args.hostname,'--hosts',args.file1,'--privkey',args.file2,'--pubkey',args.file3,'--mgmt-nic','ens20','--mgmt-ip',args.mgmt_ip,'--mgmt-prefix',args.mgmt_prefix,'--mgmt-gw',args.mgmt_gw,'--dns','8.8.8.8','--pn-nic','ens21','--pn-ip',args.pn_ip,'--pn-prefix',args.pn_prefix,'--cn-nic','ens22','--cn-ip',args.cn_ip,'--cn-prefix',args.cn_prefix,'--iso-path',pluginpath+'/tools/vmconfig/scvm/scvm-cloudinit.iso','scvm').stdout.decode())
    if result['code'] not in [200]:
        success_bool = False

    # 결과값 리턴
    if success_bool:
        return createReturn(code=200, val="scvm cloudinit iso create success")
    else:
        return createReturn(code=500, val="scvm cloudinit iso create fail")
示例#21
0
def import_module(name):
    '''
        Import with debugging

        >>> module = import_module("syr.user")
        >>> if IS_PY2:
        ...     str(module) == "<module 'syr.user' from '/usr/local/lib/python2.7/dist-packages/syr/user.pyc'>"
        ... else:
        ...     str(module) == "<module 'syr.user' from '/usr/local/lib/python3.4/dist-packages/syr/user.py'>"
        True
    '''

    try:
        log('import_module({})'.format(name)) #DEBUG
        module = importlib.import_module(name)
        log('import_module() result: {}'.format(module)) #DEBUG
    except ImportError as imp_error:
        log('unable to import {}'.format(name))
        log('ImportError: ' + str(imp_error))
        msg = 'could not import {}'.format(name)
        log(msg)
        # find out why
        if IS_PY2:
            log(sh.python('-c', 'import {}'.format(name)).stderr)
        else:
            log(sh.python3('-c', 'import {}'.format(name)).stderr)
        raise BuildException(msg)
    return module
示例#22
0
文件: test.py 项目: fjstinar/pySRURGS
 def test_cli_funcs_arity_two(self):
     output = sh.python3('pySRURGS.py', '-deterministic',
                         '-funcs_arity_two', 'add,sub,div',
                         '-max_num_fit_params', 1, '-path_to_db',
                         working_db, qrtic_polynml_csv, num_iters * 10)
     output = output.strip()
     print(output)
     n_results = count_results(working_db)
     result_list = get_resultlist(working_db)
     self.assertGreater(n_results, 0.98 * num_iters)
     flag1 = False
     flag2 = False
     flag3 = False
     for i in range(0, n_results):
         my_result = result_list._results[i]
         eqn = my_result._equation
         self.assertEqual(('mul' in eqn), False)
         self.assertEqual(('exp' in eqn), False)
         if 'add' in eqn:
             flag1 = True
         if 'sub' in eqn:
             flag2 = True
         if 'div' in eqn:
             flag3 = True
     self.assertEqual(flag1, True)
     self.assertEqual(flag2, True)
     self.assertEqual(flag3, True)
 def test_cli_funcs_arity_two(self):
     output = sh.python3('symbolic_regression.py', '-deterministic', True,
                         '-funcs_arity_two', 'add,sub,div',
                         '-max_num_fit_params', 1, self._dataset_path,
                         self._output_db)
     output = output.strip()
     print(output)
 def test_cli_combo_params_exhaustive_2(self):
     output = sh.python3('symbolic_regression.py', '-exhaustive', True,
                         '-funcs_arity_two', 'add,sub',
                         '-max_permitted_trees', 3, '-max_num_fit_params',
                         1, self._dataset_path, self._output_db)
     output = output.strip()
     print(output)
示例#25
0
文件: test.py 项目: fjstinar/pySRURGS
 def test_cli_funcs_arity_one(self):
     output = sh.python3('pySRURGS.py', '-deterministic',
                         '-funcs_arity_one', 'tan,exp,sinh,cosh',
                         '-funcs_arity_two', 'add', '-max_num_fit_params',
                         1, '-path_to_db', working_db, qrtic_polynml_csv,
                         num_iters * 20)
     output = output.strip()
     print(output)
     n_results = count_results(working_db)
     result_list = get_resultlist(working_db)
     self.assertGreater(n_results, 0.98 * num_iters)
     flag1 = False
     flag2 = False
     flag3 = False
     flag4 = False
     for i in range(0, n_results):
         my_result = result_list._results[i]
         simple_eqn = my_result._simple_equation
         if 'cosh' in simple_eqn:
             flag1 = True
         if 'tan' in simple_eqn:
             flag2 = True
         if 'sinh' in simple_eqn:
             flag3 = True
         if 'exp' in simple_eqn:
             flag4 = True
     self.assertEqual(flag1, True)
     self.assertEqual(flag2, True)
     self.assertEqual(flag3, True)
     self.assertEqual(flag4, True)
示例#26
0
 def get_lines(self, repo_path):
     with sh.pushd(repo_path):
         a = sh.python3('-c', ugly_one_liner)
         lines = [
             x for x in a.stdout.decode('utf-8').split('\n') if '>>>' in x
         ]
         return lines
 def test_multiprocessing_performance(self):
     time0 = time.time()
     sh.python3('./symbolic_regression_lite.py', '-weights',
                './weights.csv', '-num_iters', '1000',
                '-simplify_solutions', 'False', './weights_data.csv',
                './test_output.json')
     time1 = time.time()
     diff1 = time1 - time0
     sh.python3('./symbolic_regression_lite.py', '-weights',
                './weights.csv', '-multiprocessing', 'True',
                '-simplify_solutions', 'False', '-num_iters', '1000',
                './weights_data.csv', './test_output.json')
     time2 = time.time()
     diff2 = time2 - time1
     print("Single Processing:", diff1)
     print("Multiprocessing:", diff2)
     print("Number cores:", multiprocessing.cpu_count())
示例#28
0
文件: test.py 项目: fjstinar/pySRURGS
 def test_cli_five_fit_params(self):
     output = sh.python3('pySRURGS.py', '-deterministic',
                         '-max_num_fit_params', 5, '-path_to_db',
                         working_db, qrtic_polynml_csv, num_iters)
     output = output.strip()
     print(output)
     n_results = count_results(working_db)
     self.assertGreater(n_results, 0.98 * num_iters)
 def test_cli_funcs_arity_one(self):
     output = sh.python3('symbolic_regression.py', '-deterministic', True,
                         '-funcs_arity_one', 'tan,exp,sinh,cosh',
                         '-funcs_arity_two', 'add', '-max_num_fit_params',
                         1, '-path_to_db', working_db, self._dataset_path,
                         self._output_db)
     output = output.strip()
     print(output)
示例#30
0
文件: maker.py 项目: zerod4y/zeronet
def run_codegen(templates, destination):
    print('Running codegen')

    print(
        python3('.components/codegen/gen.py', template=templates,
            output=destination,
            )
        )
示例#31
0
文件: test.py 项目: fjstinar/pySRURGS
 def test_cli_single_processor_deterministic(self):
     output = sh.python3('pySRURGS.py', '-single', '-deterministic',
                         '-path_to_db', working_db, qrtic_polynml_csv,
                         num_iters)
     output = output.strip()
     print(output)
     n_results = count_results(working_db)
     self.assertGreater(n_results, 0.95 * num_iters)
示例#32
0
def pcsCleanup():
    try:
        ret = sh.python3(pluginpath + "/python/pcs/main.py","cleanup", "--resource", "cloudcenter_res").stdout.decode()
    except Exception as e:
        ret = createReturn(code=500, val='ERROR')
        print ('EXCEPTION : ',e)
    
    return ret
示例#33
0
def test_filter_empty_group():
    file = 'test/program_output_empty_group'
    filtered_output_file = 'test/program_output_filtered_empty_group'
    # Test with the file passed as a parameter.
    output = StringIO()
    python3(path2main,
            file,
            start_pattern=start_pattern,
            error_pattern=error_pattern,
            start_group=
            '#### (?P<command>.+) - (?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2})',
            end_group='#### END',
            mail_to='*****@*****.**',
            _out=output)

    with open(filtered_output_file, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
def setupPcsCluster(args):

    success_bool = True

    #=========== pcs cluster 구성 ===========
    # ceph 이미지 등록
    os.system(
        "qemu-img convert -f qcow2 -O rbd /var/lib/libvirt/images/ablestack-template-back.qcow2 rbd:rbd/ccvm"
    )

    # 클러스터 구성
    result = json.loads(
        python3(pluginpath + '/python/pcs/main.py', 'config', '--cluster',
                'cloudcenter_cluster', '--hosts', args.host_names[0],
                args.host_names[1], args.host_names[2]).stdout.decode())
    if result['code'] not in [200]:
        success_bool = False

    # 리소스 생성
    result = json.loads(
        python3(pluginpath + '/python/pcs/main.py', 'create', '--resource',
                'cloudcenter_res', '--xml',
                pluginpath + '/tools/vmconfig/ccvm/ccvm.xml').stdout.decode())
    if result['code'] not in [200]:
        success_bool = False

    #ccvm이 정상적으로 생성 되었는지 확인
    domid_check = ""
    cnt_num = 0
    while True:
        time.sleep(1)
        cnt_num += 1
        domid_check = os.system("virsh domid ccvm > /dev/null")
        if domid_check == 0 or cnt_num > 60:
            break

    if domid_check != 0:
        success_bool = False

    # 결과값 리턴
    if success_bool:
        return createReturn(code=200, val="cloud center setup success")
    else:
        return createReturn(code=500, val="cloud center setup fail")
示例#35
0
文件: test.py 项目: fjstinar/pySRURGS
 def test_cli_combo_params_exhaustive_2(self):
     output = sh.python3('pySRURGS.py', '-exhaustive', '-funcs_arity_two',
                         'add,sub', '-max_permitted_trees', 3,
                         '-max_num_fit_params', 1, '-path_to_db',
                         working_db, qrtic_polynml_csv, 10)
     output = output.strip()
     print(output)
     self.assertEqual('42.0' in output, True)
     n_results = count_results(working_db)
     result_list = get_resultlist(working_db)
     self.assertEqual(n_results, 18)  # 24 trees must simplify
示例#36
0
文件: test.py 项目: fjstinar/pySRURGS
 def test_cli_zero_fit_params(self):
     output = sh.python3('pySRURGS.py', '-deterministic',
                         '-max_num_fit_params', 0, '-path_to_db',
                         working_db, qrtic_polynml_csv, num_iters)
     output = output.strip()
     print(output)
     result_list = get_resultlist(working_db)
     n_results = count_results(working_db)
     self.assertGreater(n_results, 0.9 * num_iters)
     for i in range(0, n_results):
         self.assertEqual(len(result_list._results[i]._params), 0)
示例#37
0
def test_filter_end_file():
    file = 'test/program_output_end_file'
    filtered_output_file = 'test/program_output_filtered_end_file'
    # Test with the file passed as a parameter.
    output = StringIO()
    python3(path2main, file,
            start_pattern=start_pattern,
            error_pattern=error_pattern,
            _out=output)

    with open(filtered_output_file, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()

    # Test with stdout
    output = StringIO()
    python3(cat(file), path2main,
        start_pattern=start_pattern,
        error_pattern=error_pattern,
        _out=output)

    with open(filtered_output_file, 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#38
0
    def start(self):
        ''' Start proxy '''

        self.namespace.log.debug('start {}'.format(self))

        # if True:
        with sudo(USER):

            if use_usewithtor:
                self.namespace.log.debug('start with usewithtor {}'.format(self)) #DEBUG
                self.web_process = sh.usewithtor.python(
                    self.program,
                    _out=self.process_output, _err=self.process_output, _bg=True)
                self.namespace.log.debug('started with usewithtor {}'.format(self)) #DEBUG

            else:
                import sh
                self.namespace.log.debug('start without usewithtor {}'.format(self)) #DEBUG
                self.web_process = sh.python3(
                    self.program,
                    _out=self.process_output, _err=self.process_output, _bg=True)
                self.namespace.log.debug('started without usewithtor {}'.format(self)) #DEBUG
示例#39
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
## Autor: David Ochoa

from sh import python3

python3('tutorial-01.py')
python3('tutorial-02.py')
python3('tutorial-03.py')
python3('tutorial-04.py')
python3('tutorial-04-color.py')
python3('tutorial-05.py')
python3('tutorial-06.py')
python3('tutorial-07.py')
python3('tutorial-08.py')
python3('tutorial-08-segments.py')
python3('tutorial-09.py')
示例#40
0
import sh
import re

commit_count = sh.git('rev-list', ['--all']).count('\n')

with open('setup.py') as f:
    setup = f.read()

setup = re.sub("MICRO_VERSION = '[0-9]+'", "MICRO_VERSION = '{}'".format(commit_count), setup)

major = re.search("MAJOR_VERSION = '([0-9]+)'", setup).groups()[0]
minor = re.search("MINOR_VERSION = '([0-9]+)'", setup).groups()[0]
micro = re.search("MICRO_VERSION = '([0-9]+)'", setup).groups()[0]
version = '{}.{}.{}'.format(major, minor, micro)

with open('setup.py', 'w') as f:
    f.write(setup)

with open('sky/__init__.py') as f:
    init = f.read()

with open('sky/__init__.py', 'w') as f:
    f.write(re.sub('__version__ = "[0-9.]+"', '__version__ = "{}"'.format(version), init))

print(sh.python3('setup.py', ['bdist_wheel', 'upload']))

sh.cd('../')

sh.pip3('install', ['-U', 'sky'])
示例#41
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
## Autor: David Ochoa

from sh import python3

python3('runme_balloon.py')
python3('runme_ball.py')
python3('runme_ball2.py')
python3('runme_bubble.py')
python3('runme_bubble2.py')
python3('runme_ball_trace.py')
示例#42
0
def test_filter_group():
    output = StringIO()
    python3(path2main, 'test/program_output_group', config=config_file, _out=output)

    with open('test/program_output_filtered_group', 'r') as correctly_filtered_output:
        assert correctly_filtered_output.read() == output.getvalue()
示例#43
0
def test_mail_empty_mail_group():
    output = StringIO()
    python3(path2main, 'test/program_output_mail_empty_group', config=config_file, _err=output)

    correctly_filtered_output = ''
    assert correctly_filtered_output == output.getvalue()
示例#44
0
def run_codegen(templates, destination):
    python3('.components/codegen/gen.py', template=templates,
            output=destination)