예제 #1
0
    async def on_message(self, message):
        # don't reply to self
        if message.author == self.user:
            return
        if message.content.startswith('!shell_exec'):
            msg = message.content.split(' ')
            if len(msg) <= 1:
                return

            msg = utils.run_command(msg[1:])
            await self.send_message(message.channel, msg.decode("utf-8"))
예제 #2
0
    async def on_message(self,message):
        # don't reply to self
        if message.author == self.user:
            return
        if message.content.startswith('!shell_exec'):
            msg = message.content.split(' ')
            if len(msg) <= 1:
                return

            msg = utils.run_command(msg[1:])
            await self.send_message(message.channel, msg.decode("utf-8"))
예제 #3
0
    def generate_table(self, command, headers=None):
        status, stdout, stderr = utilities.run_command(command)
        # if success running the command, otherwise else
        if(status == 0):
            # the rows are separated by  '\n' so we need to split it
            self.command_output = stdout.decode('utf-8').split('\n')
            self.set_headers(headers)
            num_fields = len(self.table_headers)
            # initialize the table as PrettyTable to use its features with
            # headers from output, and add content
            self.content_table = PrettyTable(self.table_headers)
            self.add_content(self.command_output, num_fields)
        else:
            self.content_table = stdout

        return self.content_table
예제 #4
0
 def _call_r_script(self):
     template = '/usr/bin/Rscript--vanilla {source}/terran_scripts/glmnetWrapper.R -X {modeling}X.csv -y {modeling}/y.csv -w {modeling}/w.csv -p {modeling}/predictors.input.csv'
     command = template.format(
         source_dir=self.research_context.get_source_directory(),
         modeling=self.research_context.get_modeling_direcectory())
     utilities.run_command(command)
예제 #5
0
파일: __init__.py 프로젝트: rossdylan/GIBSY
 def update(self):
     current_dir = os.getcwd()
     os.chdir(self.config['git_clone'])
     util.run_command("git pull origin master")
     os.chdir(current_dir)
예제 #6
0
파일: test.py 프로젝트: Sanyam07/sdc
            sys.exit(0)

        coverage_omit = './sdc/tests/*'
        coverage_cmd = ' && '.join([
            'coverage erase',
            f'coverage run --source=./sdc --omit {coverage_omit} ./sdc/runtests.py',
            'coveralls -v'
        ])

        format_print('Run coverage')
        format_print(
            f'Assume that SDC is installed in develop build-mode to {develop_env} environment',
            new_block=False)
        format_print('Install scipy and coveralls')
        run_command(
            f'{develop_env_activate} && conda install -q -y scipy coveralls coverage=4'
        )
        run_command(
            f'{develop_env_activate} && python -m sdc.tests.gen_test_data')
        run_command(f'{develop_env_activate} && {coverage_cmd}')
        sys.exit(0)

    if test_mode == 'develop':
        format_print(f'Run tests for sdc installed to {develop_env}')
        """
        os.chdir(../sdc_src) is a workaround for the following error:
        Traceback (most recent call last):
            File "<string>", line 1, in <module>
            File "sdc/sdc/__init__.py", line 9, in <module>
                import sdc.dict_ext
            File "sdc/sdc/dict_ext.py", line 12, in <module>
예제 #7
0
def run_smoke_tests(sdc_src, test_env_activate):
    sdc_pi_example = os.path.join(sdc_src, 'buildscripts', 'sdc_pi_example.py')
    run_command(f'{test_env_activate} && python -c "import sdc"')
    run_command(f'{test_env_activate} && python {sdc_pi_example}')
예제 #8
0
            set_environment_variable(
                'LIB', os.path.join('%CONDA_PREFIX%', 'Library', 'lib'))

        conda_build_packages.extend([
            'conda-verify', 'vc', 'vs2015_runtime', 'vs2015_win-64',
            'pywin32=223'
        ])

    # Build Numba from master
    if use_numba_master is True:
        create_conda_env(conda_activate, build_env, python,
                         conda_build_packages)
        format_print('Start build Numba from master')
        run_command('{} && {}'.format(
            build_env_activate, ' '.join([
                'conda build --no-test', f'--python {python}',
                f'--numpy {numpy}', f'--output-folder {numba_output_folder}',
                f'{numba_conda_channels} {numba_recipe}'
            ])))
        format_print('NUMBA BUILD COMPETED')

    # Get sdc build and test environment
    sdc_env = get_sdc_env(conda_activate, sdc_src, sdc_recipe, python, numpy,
                          conda_channels)

    # Set build command
    if build_mode == 'package':
        create_conda_env(conda_activate, build_env, python,
                         conda_build_packages)
        build_cmd = '{} && {}'.format(
            build_env_activate, ' '.join([
                'conda build --no-test', f'--python {python}',
예제 #9
0
def install():
    cwd = os.getcwd()
    install_here = util.yorn("Install to current directory?")
    if install_here:
        install_path = cwd
    else:
        install_path = raw_input("Enter an install path; ")
    blog_name = raw_input("Enter a blog name: ")
    os.chdir(install_path)
    print "Creating Git Repository"
    git_repo = os.path.join(install_path,blog_name + ".git")
    os.mkdir(git_repo)
    os.chdir(git_repo)
    util.run_command("git init --bare")
    os.chdir(install_path)
    print "Cloning Git Repository"
    util.run_command("git clone %s" % git_repo)
    git_clone = os.path.join(install_path,blog_name)
    print "Creating Gibsy File Structure"
    os.chdir(git_clone)
    os.mkdir("posts")
    util.run_command("touch posts/first.post")
    config_path = os.path.join(git_clone, "gibsy.conf")
    git_hook = generate_git_hook(config_path)
    with open("gibsy.conf", "w") as f:
        DEFAULT_CONFIG.update({"git_repo": git_repo, "git_clone": git_clone, "pid_path": os.path.join(git_clone,"gibsy.pid")})
        f.write(json.dumps(DEFAULT_CONFIG))
    print "Commiting and pushing fle structure"
    util.run_command("git add posts/first.post gibsy.conf")
    util.run_command("git commit -m 'initial commit'")
    util.run_command("git push origin master")
    print "Creating git hook"
    os.chdir(git_repo)
    with open("hooks/post-receive","w") as f:
        f.write(git_hook)
    os.chdir(cwd)
예제 #10
0
    if build_mode == 'package':
        create_conda_env(conda_activate, build_env, python,
                         conda_build_packages)
        build_cmd = '{} && {}'.format(
            build_env_activate, ' '.join([
                'conda build --no-test', f'--python {python}',
                f'--numpy={numpy}', f'--output-folder {output_folder}',
                f'--prefix-length 10 {sdc_recipe}'
            ]))
    else:
        create_conda_env(conda_activate, develop_env, python, sdc_env['build'])
        build_cmd = f'{develop_env_activate} && python setup.py {build_mode}'

    # Start build
    format_print('Start build')
    run_command(build_cmd)
    format_print('BUILD COMPETED')

    # Check if smoke tests should be skipped
    if skip_smoke_tests == True:
        format_print(
            'Smoke tests are skipped due to "--skip-smoke-tests" option')
        sys.exit(0)

    # Start smoke tests
    format_print('Run Smoke tests')
    """
    os.chdir(../sdc_src) is a workaround for the following error:
    Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "hpat/hpat/__init__.py", line 9, in <module>
예제 #11
0
    def make_report(self, path):
        with self.setup_latex_dir():
            self.setup_benchmark_colors()

            tex_path = os.path.join(self.latex_dir, 'report.tex')
            pdf_path = os.path.join(self.latex_dir, 'report.pdf')

            chapter_paths = []

            chapter_path = self.make_comparison_chapter()
            if chapter_path is not None:
                chapter_paths.append(chapter_path)

            for benchmark in self:
                chapter_path = self.make_benchmark_chapter(benchmark)
                chapter_paths.append(chapter_path)

            report_template = '''\
\\documentclass{{report}}

\\usepackage{{booktabs}}
\\usepackage{{graphicx}}
\\usepackage{{fullpage}}
\\usepackage{{hyperref}}

\\renewcommand{{\\textfraction}}{{0.00}}

\\hypersetup{{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}}

\\begin{{document}}

\\title{{Loop Benchmark Report}}
\\author{{{author}}}
\\maketitle
\\tableofcontents

{chapters}

\\end{{document}}
'''
            author = ''
            chapters = '\n'.join('\input{{{0}}}'.format(path)
                                 for path in chapter_paths)

            with open(tex_path, 'w') as file:
                file.write(report_template.format(**locals()))

            print "Running pdflatex..."

            if self.verbose:
                tex_command = 'pdflatex', 'report.tex'
            else:
                tex_command = 'pdflatex', '-interaction=batchmode', 'report.tex'

            utilities.run_command(tex_command,
                                  cwd=self.latex_dir,
                                  verbose=self.verbose)
            utilities.run_command(tex_command,
                                  cwd=self.latex_dir,
                                  verbose=self.verbose)
            shutil.copy(pdf_path, path)
예제 #12
0
파일: test.py 프로젝트: sklam/sdc
            format_print('Coverage can be run only on Linux of mac for now')
            sys.exit(0)

        coverage_omit = './sdc/tests/*'
        coverage_cmd = ' && '.join([
            'coverage erase',
            f'coverage run --source=./sdc --omit {coverage_omit} ./sdc/runtests.py',
            'coveralls -v'
        ])

        format_print('Run coverage')
        format_print(
            f'Assume that SDC is installed in develop build-mode to {develop_env} environment',
            new_block=False)
        format_print('Install scipy and coveralls')
        run_command(
            f'{develop_env_activate} && conda install -q -y scipy coveralls')
        run_command(
            f'{develop_env_activate} && python -m sdc.tests.gen_test_data')
        run_command(f'{develop_env_activate} && {coverage_cmd}')
        sys.exit(0)

    if test_mode == 'develop':
        format_print(f'Run tests for sdc installed to {develop_env}')
        """
        os.chdir(../sdc_src) is a workaround for the following error:
        Traceback (most recent call last):
            File "<string>", line 1, in <module>
            File "sdc/sdc/__init__.py", line 9, in <module>
                import sdc.dict_ext
            File "sdc/sdc/dict_ext.py", line 12, in <module>
                from sdc.str_ext import string_type, gen_unicode_to_std_str, gen_std_str_to_unicode