Python os.EX_OK() Examples

The following are code examples for showing how to use os.EX_OK(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: bbq   Author: ocadotechnology   File: isolation_test.py    Apache License 2.0 6 votes vote down vote up
def execute_all_tests_recursively(self):

        print "CHECKING TESTS DIRECTORY: {}".format(self.test_path)
        for dirpath, _, _ in os.walk(self.test_path):
            for test_file in os.listdir(dirpath):
                if test_file.startswith('test') and test_file.endswith('.py'):
                    self.execute_single_file_tests(self.test_path, test_file)

        if self.errors_count == 0:
            print "DONE. Everyting fine."
            sys.exit(os.EX_OK)
        else:
            print "ERROR. There {} {} {}, that went wrong in isolation".format(
                'is' if self.errors_count == 1 else "are",
                self.errors_count,
                'test file' if self.errors_count == 1 else "test files"
            )
            sys.exit(os.O_WRONLY) 
Example 2
Project: eden   Author: facebookexperimental   File: main.py    GNU General Public License v2.0 6 votes vote down vote up
def main() -> int:
    # Before doing anything else check that the current working directory is valid.
    # This helps catch the case where a user is trying to run the Eden CLI inside
    # a stale eden mount point.
    stale_return_code = check_for_stale_working_directory()
    if stale_return_code is not None:
        return stale_return_code

    parser = create_parser()
    args = parser.parse_args()
    if args.version:
        return do_version(args)
    if getattr(args, "func", None) is None:
        parser.print_help()
        return EX_OK
    try:
        return_code: int = args.func(args)
    except subcmd_mod.CmdError as ex:
        print(f"error: {ex}", file=sys.stderr)
        return EX_SOFTWARE
    except config_mod.UsageError as ex:
        print(f"error: {ex}", file=sys.stderr)
        return EX_USAGE
    return return_code 
Example 3
Project: python-tldp   Author: tLDP   File: driver.py    MIT License 6 votes vote down vote up
def build(config, docs, **kwargs):
    if not config.pubdir:
        return ERR_NEEDPUBDIR + "to --build"
    ready, error = builddir_setup(config)
    if not ready:
        return error
    ready, error = prepare_docs_build_mode(config, docs)
    if not ready:
        return error
    buildsuccess, results = docbuild(config, docs, **kwargs)
    for x, (buildcode, source) in enumerate(results, 1):
        if buildcode:
            logger.info("success (%d of %d) available in %s",
                        x, len(results), source.working.dirname)
        else:
            logger.info("FAILURE (%d of %d) available in %s",
                        x, len(results), source.working.dirname)
    if buildsuccess:
        return os.EX_OK
    else:
        return "Build failed, see logging output in %s." % (config.builddir,) 
Example 4
Project: python-tldp   Author: tLDP   File: driver.py    MIT License 6 votes vote down vote up
def publish(config, docs, **kwargs):
    config.build = True
    result = build(config, docs, **kwargs)
    if result != os.EX_OK:
        return result
    for x, source in enumerate(docs, 1):
        logger.info("Publishing (%d of %d) to %s.",
                    x, len(docs), source.output.dirname)
        # -- swapdirs must raise an error if there are problems
        #
        swapdirs(source.working.dirname, source.output.dirname)
        if os.path.isdir(source.working.dirname):
            logger.debug("%s removing old directory %s",
                         source.stem, source.working.dirname)
            shutil.rmtree(source.working.dirname)
    workingdirs = list(set([x.dtworkingdir for x in docs]))
    workingdirs.append(config.builddir)
    post_publish_cleanup(workingdirs)
    return os.EX_OK 
Example 5
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 6 votes vote down vote up
def test_summary_longnames(self):
        c = self.config
        names = self.publishDocumentsWithLongNames(5)
        stdout = io.StringIO()
        result = tldp.driver.summary(c, file=stdout)
        self.assertEqual(result, os.EX_OK)
        stdout.seek(0)
        data = stdout.read()
        self.assertTrue('and 4 more' in data)
        c.verbose = True
        stdout = io.StringIO()
        result = tldp.driver.summary(c, file=stdout)
        self.assertEqual(result, os.EX_OK)
        stdout.seek(0)
        data = stdout.read()
        for name in names:
            self.assertTrue(name in data) 
Example 6
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 6 votes vote down vote up
def test_run(self):
        c = self.config
        ex = example.ex_linuxdoc
        self.add_published('Published-HOWTO', ex)
        self.add_new('New-HOWTO', ex)
        self.add_stale('Stale-HOWTO', ex)
        self.add_orphan('Orphan-HOWTO', ex)
        self.add_broken('Broken-HOWTO', ex)
        fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
        argv = self.argv
        argv.extend(['--publish', 'stale', 'Orphan-HOWTO', fullpath])
        exitcode = tldp.driver.run(argv)
        self.assertEqual(exitcode, os.EX_OK)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(4, len(inv.published.keys()))
        self.assertEqual(1, len(inv.broken.keys())) 
Example 7
Project: jipdate   Author: Linaro   File: jipdate.py    MIT License 5 votes vote down vote up
def main(argv):
    parser = get_parser()

    # The parser arguments (cfg.args) are accessible everywhere after this call.
    cfg.args = parser.parse_args()

    # This initiates the global yml configuration instance so it will be
    # accessible everywhere after this call.
    cfg.initiate_config()

    if not cfg.args.file and not cfg.args.q:
        eprint("No file provided and not in query mode\n")
        parser.print_help()
        sys.exit(os.EX_USAGE)

    jira, username = jiralogin.get_jira_instance(cfg.args.t)

    if cfg.args.x or cfg.args.e:
        if not cfg.args.q:
            eprint("Arguments '-x' and '-e' can only be used together with '-q'")
            sys.exit(os.EX_USAGE)

    if cfg.args.p and not cfg.args.q:
        eprint("Arguments '-p' can only be used together with '-q'")
        sys.exit(os.EX_USAGE)

    if cfg.args.q:
        filename = get_jira_issues(jira, username)

        if cfg.args.p:
            print_status_file(filename)
            sys.exit(os.EX_OK)
    elif cfg.args.file is not None:
        filename = cfg.args.file
    else:
        eprint("Trying to run script with unsupported configuration. Try using --help.")
        sys.exit(os.EX_USAGE)

    if get_editor():
        open_editor(filename)
    parse_status_file(jira, filename) 
Example 8
Project: qatrfm-lib   Author: jlausuch   File: testcase.py    GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        """
        Execution of the test case.

        This method must be overriden by the children and implement the
        flow of the test. If everything is ok, self.EX_OK should be returned.
        Otherwise, self.EX_FAILURE should be returned.
        """
        return self.EX_OK 
Example 9
Project: airflow   Author: apache   File: dag_processing.py    Apache License 2.0 5 votes vote down vote up
def _exit_gracefully(self, signum, frame):  # pylint: disable=unused-argument
        """
        Helper method to clean up DAG file processors to avoid leaving orphan processes.
        """
        self.log.info("Exiting gracefully upon receiving signal %s", signum)
        self.terminate()
        self.end()
        self.log.debug("Finished terminating DAG processors.")
        sys.exit(os.EX_OK) 
Example 10
Project: airflow   Author: apache   File: scheduler_job.py    Apache License 2.0 5 votes vote down vote up
def _exit_gracefully(self, signum, frame):
        """
        Helper method to clean up processor_agent to avoid leaving orphan processes.
        """
        self.log.info("Exiting gracefully upon receiving signal %s", signum)
        if self.processor_agent:
            self.processor_agent.end()
        sys.exit(os.EX_OK) 
Example 11
Project: batemaneq   Author: bjodah   File: test_native.py    BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_native():
    cwd = os.path.dirname(__file__)
    if cwd == '':
        cwd = None
    p = subprocess.Popen(['make', '-B'], cwd=cwd)
    assert p.wait() == os.EX_OK

    p = subprocess.Popen(['make', '-B', 'MULTIPRECISION_DIGITS10=32'], cwd=cwd)
    assert p.wait() == os.EX_OK 
Example 12
Project: yq   Author: kislyuk   File: test.py    Apache License 2.0 5 votes vote down vote up
def run_yq(self, input_data, args, expect_exit_codes={os.EX_OK}, input_format="yaml"):
        stdin, stdout = sys.stdin, sys.stdout
        try:
            sys.stdin = io.StringIO(input_data)
            sys.stdout = io.BytesIO() if USING_PYTHON2 else io.StringIO()
            cli(args, input_format=input_format)
        except SystemExit as e:
            self.assertIn(e.code, expect_exit_codes)
        finally:
            result = sys.stdout.getvalue()
            if USING_PYTHON2:
                result = result.decode("utf-8")
            sys.stdin, sys.stdout = stdin, stdout
        return result 
Example 13
Project: gmfwtools   Author: zzerrg   File: gm_app_fw.py    Apache License 2.0 5 votes vote down vote up
def main(args):
    if args.offset:
        if args.offset[0:2] == '0x':
            offset = int(args.offset[2:], 16)
        else:
            offset = int(args.offset)
    else:
        offset = 0
    fw = GMAppFirmware(args.fn, offset=offset, verbose=args.debug,
                       fw_version=args.fw_version)
    if args.verify:
        is_ok = fw.do_verify()
        sys.exit(os.EX_OK if is_ok else os.EX_DATAERR)
    elif args.unpack:
        fw.do_unpack(args.out_fn, args.exec_fn)
    elif args.mount:
        if args.target:
            fw.do_mount(mpoint=args.target)
        else:
            fw.do_mount()
    elif args.pack:
        fw.do_pack(args.jffs_image, args.exec_fn)
    elif args.key:
        fw.do_key(args.key, False)
    elif args.keybrute:
        fw.do_key(None, True)
    else:
        print("Usage: one of -v, -u or -p options should be specified")
        sys.exit(os.EX_USAGE) 
Example 14
Project: poetrify   Author: kk6   File: test_poetrify.py    MIT License 5 votes vote down vote up
def test_foo_dry_run(command_tester_factory):
    command_tester = command_tester_factory("generate")
    with pytest.raises(SystemExit) as pytest_wrapped_exit:
        command_tester.execute("-d -w repos/foo")
    assert pytest_wrapped_exit.type == SystemExit
    assert pytest_wrapped_exit.value.code == os.EX_OK
    assert (
        "poetry init --dependency=scrapy --dependency=beautifulsoup4 --dev-dependency=pytest --license=MIT"
        in command_tester.io.fetch_output()
    ) 
Example 15
Project: python-tldp   Author: tLDP   File: driver.py    MIT License 5 votes vote down vote up
def script(config, docs, **kwargs):
    ready, error = prepare_docs_script_mode(config, docs)
    if not ready:
        return error
    file = kwargs.get('file', sys.stdout)
    print(preamble, file=file)
    buildsuccess, results = docbuild(config, docs, **kwargs)
    print(postamble, file=file)
    for errcode, source in results:
        if not errcode:
            logger.error("Could not generate script for %s", source.stem)
    if buildsuccess:
        return os.EX_OK
    else:
        return "Script generation failed." 
Example 16
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_run_detail(self):
        self.add_published('Published-HOWTO', example.ex_linuxdoc)
        self.add_new('New-HOWTO', example.ex_linuxdoc)
        self.add_stale('Stale-HOWTO', example.ex_linuxdoc)
        self.add_orphan('Orphan-HOWTO', example.ex_linuxdoc)
        self.add_broken('Broken-HOWTO', example.ex_linuxdoc)
        argv = self.argv
        argv.append('--detail')
        exitcode = tldp.driver.run(argv)
        self.assertEqual(exitcode, os.EX_OK) 
Example 17
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_run_doctypes(self):
        exitcode = tldp.driver.run(['--doctypes'])
        self.assertEqual(exitcode, os.EX_OK) 
Example 18
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_show_statustypes(self):
        stdout = io.StringIO()
        result = tldp.driver.show_statustypes(Namespace(), file=stdout)
        self.assertEqual(result, os.EX_OK)
        stdout.seek(0)
        data = stdout.read()
        for status in status_types:
            self.assertTrue(stypes[status] in data) 
Example 19
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_run_statustypes(self):
        exitcode = tldp.driver.run(['--statustypes'])
        self.assertEqual(exitcode, os.EX_OK) 
Example 20
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_run_summary(self):
        self.add_published('Published-HOWTO', example.ex_linuxdoc)
        self.add_new('New-HOWTO', example.ex_linuxdoc)
        self.add_stale('Stale-HOWTO', example.ex_linuxdoc)
        self.add_orphan('Orphan-HOWTO', example.ex_linuxdoc)
        self.add_broken('Broken-HOWTO', example.ex_linuxdoc)
        argv = self.argv
        argv.append('--summary')
        exitcode = tldp.driver.run(argv)
        self.assertEqual(exitcode, os.EX_OK) 
Example 21
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_run_no_work(self):
        self.add_published('Published-HOWTO', example.ex_linuxdoc)
        exitcode = tldp.driver.run(self.argv)
        # -- improvement: check for 'No work to do.' from logger
        self.assertEqual(exitcode, os.EX_OK) 
Example 22
Project: python-tldp   Author: tLDP   File: test_driver.py    MIT License 5 votes vote down vote up
def test_run_script(self):
        self.add_published('Published-HOWTO', example.ex_linuxdoc)
        self.add_new('New-HOWTO', example.ex_linuxdoc)
        self.add_stale('Stale-HOWTO', example.ex_linuxdoc)
        self.add_orphan('Orphan-HOWTO', example.ex_linuxdoc)
        self.add_broken('Broken-HOWTO', example.ex_linuxdoc)
        argv = self.argv
        argv.append('--script')
        exitcode = tldp.driver.run(argv)
        self.assertEqual(exitcode, os.EX_OK) 
Example 23
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_run_status_selection(self):
        self.add_docbook4xml_xsl_to_config()
        c = self.config
        self.add_stale('Asciidoc-Stale-HOWTO', example.ex_asciidoc)
        self.add_new('DocBook4XML-New-HOWTO', example.ex_docbook4xml)
        argv = self.argv
        argv.extend(['--publish', 'stale'])
        argv.extend(['--docbook4xml-xslprint', c.docbook4xml_xslprint])
        argv.extend(['--docbook4xml-xslchunk', c.docbook4xml_xslchunk])
        argv.extend(['--docbook4xml-xslsingle', c.docbook4xml_xslsingle])
        exitcode = tldp.driver.run(argv)
        self.assertEqual(exitcode, os.EX_OK)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(1, len(inv.published.keys())) 
Example 24
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_publish_fail_because_broken(self):
        c = self.config
        c.publish = True
        self.add_new('Frobnitz-DocBook-XML-4-HOWTO', example.ex_docbook4xml)
        self.add_stale('Broken-DocBook-XML-4-HOWTO', example.broken_docbook4xml)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(2, len(inv.all.keys()))
        docs = inv.all.values()
        exitcode = tldp.driver.publish(c, docs)
        self.assertNotEqual(exitcode, os.EX_OK) 
Example 25
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_publish_docbook4xml(self):
        self.add_docbook4xml_xsl_to_config()
        c = self.config
        c.publish = True
        self.add_new('Frobnitz-DocBook-XML-4-HOWTO', example.ex_docbook4xml)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(1, len(inv.all.keys()))
        docs = inv.all.values()
        exitcode = tldp.driver.publish(c, docs)
        self.assertEqual(exitcode, os.EX_OK)
        doc = docs.pop(0)
        self.assertTrue(doc.output.iscomplete) 
Example 26
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_publish_asciidoc(self):
        self.add_docbook4xml_xsl_to_config()
        c = self.config
        c.publish = True
        self.add_new('Frobnitz-Asciidoc-HOWTO', example.ex_asciidoc)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(1, len(inv.all.keys()))
        docs = inv.all.values()
        c.skip = []
        exitcode = tldp.driver.publish(c, docs)
        self.assertEqual(exitcode, os.EX_OK)
        doc = docs.pop(0)
        self.assertTrue(doc.output.iscomplete) 
Example 27
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_publish_linuxdoc(self):
        c = self.config
        c.publish = True
        self.add_new('Frobnitz-Linuxdoc-HOWTO', example.ex_linuxdoc)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(1, len(inv.all.keys()))
        docs = inv.all.values()
        c.skip = []
        exitcode = tldp.driver.publish(c, docs)
        self.assertEqual(exitcode, os.EX_OK)
        doc = docs.pop(0)
        self.assertTrue(doc.output.iscomplete) 
Example 28
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_publish_docbooksgml(self):
        self.add_docbooksgml_support_to_config()
        c = self.config
        c.publish = True
        self.add_new('Frobnitz-DocBookSGML-HOWTO', example.ex_docbooksgml)
        inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
        self.assertEqual(1, len(inv.all.keys()))
        docs = inv.all.values()
        exitcode = tldp.driver.publish(c, docs)
        self.assertEqual(exitcode, os.EX_OK)
        doc = docs.pop(0)
        self.assertTrue(doc.output.iscomplete) 
Example 29
Project: python-tldp   Author: tLDP   File: long_driver.py    MIT License 5 votes vote down vote up
def test_publish_docbooksgml_larger(self):
        self.add_docbooksgml_support_to_config()
        c = self.config
        c.publish = True
        doc = SourceDocument(example.ex_docbooksgml_dir.filename)
        exitcode = tldp.driver.publish(c, [doc])
        self.assertEqual(exitcode, os.EX_OK)
        self.assertTrue(doc.output.iscomplete)
        outputimages = os.path.join(doc.output.dirname, 'images')
        self.assertTrue(os.path.exists(outputimages))

#
# -- end of file 
Example 30
Project: Computable   Author: ktraunmueller   File: test_linalg.py    MIT License 4 votes vote down vote up
def test_xerbla_override():
    # Check that our xerbla has been successfully linked in. If it is not,
    # the default xerbla routine is called, which prints a message to stdout
    # and may, or may not, abort the process depending on the LAPACK package.
    from nose import SkipTest

    try:
        pid = os.fork()
    except (OSError, AttributeError):
        # fork failed, or not running on POSIX
        raise SkipTest("Not POSIX or fork failed.")

    if pid == 0:
        # child; close i/o file handles
        os.close(1)
        os.close(0)
        # Avoid producing core files.
        import resource
        resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
        # These calls may abort.
        try:
            np.linalg.lapack_lite.xerbla()
        except ValueError:
            pass
        except:
            os._exit(os.EX_CONFIG)

        try:
            a = np.array([[1]])
            np.linalg.lapack_lite.dgetrf(
                1, 1, a.astype(np.double),
                0, # <- invalid value
                a.astype(np.intc), 0)
        except ValueError as e:
            if "DGETRF parameter number 4" in str(e):
                # success
                os._exit(os.EX_OK)

        # Did not abort, but our xerbla was not linked in.
        os._exit(os.EX_CONFIG)
    else:
        # parent
        pid, status = os.wait()
        if os.WEXITSTATUS(status) != os.EX_OK or os.WIFSIGNALED(status):
            raise SkipTest('Numpy xerbla not linked in.') 
Example 31
Project: dave   Author: barentsen   File: pipeline.py    MIT License 4 votes vote down vote up
def checkDirExistTask(clip):
    """
    Code checks to see if certain directories or files exist.
    """
    modbase=clip['config.modshiftBasename']
    plotbase=clip['config.onepageBasename']  # Jeff added this
    prfdir=clip['config.prfPath']
    lppmap=clip['config.lppMapFilePath']
    datadir=clip['config.dataStorePath']
    clipdir=clip['config.clipSavePath']

    moddir=os.path.dirname(modbase)
    plotdir=os.path.dirname(plotbase)
    vetdir=getVetDir()
    vetExName="%s%s" % (vetdir, "/modshift")

    errors=[]
    try:
        open(lppmap)
    except IOError:
        errors.append(("Cannot Find LPP Map, %s " % lppmap))
    if not (os.path.exists(moddir)):
        errors.append("Cannot Find Modshift Write Dir, %s " % moddir)
    if not (os.access(moddir, os.W_OK)):
        errors.append("Cannot Write to modshift directory %s " % moddir)
    if not (os.path.exists(plotdir)):
        errors.append("Cannot Find Plotting Write Dir, %s " % plotdir)
    if not (os.access(plotdir, os.W_OK)):
        errors.append("Cannot Write to plotting directory %s " % plotdir)
    if not (os.access(clipdir,os.W_OK)):
        errors.append("Can not write to clip directory %s" % clipdir )
    if not (os.access(prfdir,os.R_OK)):
        errors.append("Cannot Read from prf Directory, %s "% prfdir)
    if not (os.access(datadir,os.R_OK)):
        errors.append("Cannot Read from Data Dir %s " % datadir)
    if not (os.access(vetExName,os.EX_OK)):
        errors.append("%s not found. Did you run make?" % vetExName )


    if len(errors) > 0:
        new="\n"
        msg=new.join(errors)
        raise IOError(msg)

    return clip 
Example 32
Project: dave   Author: barentsen   File: pipeline.py    MIT License 4 votes vote down vote up
def checkDirExistTask(clip):
    """
    Code checks to see if certain directories or files exist.
    """
    modbase=clip['config.modshiftBasename']
    plotbase=clip['config.onepageBasename']  # Jeff added this
    prfdir=clip['config.prfPath']
    lppmap=clip['config.lppMapFilePath']
    datadir=clip['config.dataStorePath']
    clipdir=clip['config.clipSavePath']

    moddir=os.path.dirname(modbase)
    plotdir=os.path.dirname(plotbase)
    vetdir=getVetDir()
    vetExName="%s%s" % (vetdir, "/modshift")

    errors=[]
    try:
        open(lppmap)
    except IOError:
        errors.append(("Cannot Find LPP Map, %s " % lppmap))
    if not (os.path.exists(moddir)):
        errors.append("Cannot Find Modshift Write Dir, %s " % moddir)
    if not (os.access(moddir, os.W_OK)):
        errors.append("Cannot Write to modshift directory %s " % moddir)
    if not (os.path.exists(plotdir)):
        errors.append("Cannot Find Plotting Write Dir, %s " % plotdir)
    if not (os.access(plotdir, os.W_OK)):
        errors.append("Cannot Write to plotting directory %s " % plotdir)
    if not (os.access(clipdir,os.W_OK)):
        errors.append("Can not write to clip directory %s" % clipdir )
    if not (os.access(prfdir,os.R_OK)):
        errors.append("Cannot Read from prf Directory, %s "% prfdir)
    if not (os.access(datadir,os.R_OK)):
        errors.append("Cannot Read from Data Dir %s " % datadir)
    if not (os.access(vetExName,os.EX_OK)):
        errors.append("%s not found. Did you run make?" % vetExName )


    if len(errors) > 0:
        new="\n"
        msg=new.join(errors)
        raise IOError(msg)

    return clip 
Example 33
Project: 3dprinteros-client   Author: panasevychol   File: test_linalg.py    GNU Affero General Public License v3.0 4 votes vote down vote up
def test_xerbla_override():
    # Check that our xerbla has been successfully linked in. If it is not,
    # the default xerbla routine is called, which prints a message to stdout
    # and may, or may not, abort the process depending on the LAPACK package.
    from nose import SkipTest

    try:
        pid = os.fork()
    except (OSError, AttributeError):
        # fork failed, or not running on POSIX
        raise SkipTest("Not POSIX or fork failed.")

    if pid == 0:
        # child; close i/o file handles
        os.close(1)
        os.close(0)
        # Avoid producing core files.
        import resource
        resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
        # These calls may abort.
        try:
            np.linalg.lapack_lite.xerbla()
        except ValueError:
            pass
        except:
            os._exit(os.EX_CONFIG)

        try:
            a = np.array([[1.]])
            np.linalg.lapack_lite.dorgqr(
                1, 1, 1, a,
                0, # <- invalid value
                a, a, 0, 0)
        except ValueError as e:
            if "DORGQR parameter number 5" in str(e):
                # success
                os._exit(os.EX_OK)

        # Did not abort, but our xerbla was not linked in.
        os._exit(os.EX_CONFIG)
    else:
        # parent
        pid, status = os.wait()
        if os.WEXITSTATUS(status) != os.EX_OK or os.WIFSIGNALED(status):
            raise SkipTest('Numpy xerbla not linked in.') 
Example 34
Project: 3dprinteros-client   Author: panasevychol   File: test_linalg.py    GNU Affero General Public License v3.0 4 votes vote down vote up
def test_xerbla_override():
    # Check that our xerbla has been successfully linked in. If it is not,
    # the default xerbla routine is called, which prints a message to stdout
    # and may, or may not, abort the process depending on the LAPACK package.
    from nose import SkipTest

    try:
        pid = os.fork()
    except (OSError, AttributeError):
        # fork failed, or not running on POSIX
        raise SkipTest("Not POSIX or fork failed.")

    if pid == 0:
        # child; close i/o file handles
        os.close(1)
        os.close(0)
        # Avoid producing core files.
        import resource
        resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
        # These calls may abort.
        try:
            np.linalg.lapack_lite.xerbla()
        except ValueError:
            pass
        except:
            os._exit(os.EX_CONFIG)

        try:
            a = np.array([[1.]])
            np.linalg.lapack_lite.dorgqr(
                1, 1, 1, a,
                0, # <- invalid value
                a, a, 0, 0)
        except ValueError as e:
            if "DORGQR parameter number 5" in str(e):
                # success
                os._exit(os.EX_OK)

        # Did not abort, but our xerbla was not linked in.
        os._exit(os.EX_CONFIG)
    else:
        # parent
        pid, status = os.wait()
        if os.WEXITSTATUS(status) != os.EX_OK or os.WIFSIGNALED(status):
            raise SkipTest('Numpy xerbla not linked in.') 
Example 35
Project: pipeline-commander   Author: cfriedt   File: pipeline-commander.py    MIT License 4 votes vote down vote up
def process_arguments( self ):

        if len( sys.argv ) is 0:
            self.usage()
            sys.exit( os.EX_OK )

        args = self.parser.parse_args()

        cfg = getattr( args, 'config' )
        if cfg:
            setattr( self, 'config', cfg )
            self.process_config( cfg_path = cfg, must_exist = True )
        else:
            setattr( self, 'config', DEFAULT_CONFIG )

        if getattr( args, 'version' ):
            print( self.version )
            sys.exit( os.EX_OK )

        for key in vars( args ):
            if 'config' is key:
                continue
            val = getattr( args, key )
            if val is not None:
                setattr( self, key, val )

        if not hasattr( self, 'private_token' ):
            self.E( "please add your private token to {0}".format( getattr( self, 'config' ) ) )
            sys.exit( errno.EINVAL )

        if not hasattr( self, 'server_url' ):
            self.E( "No server-url argument specified" )
            sys.exit( errno.EINVAL )

        self._api = api_v4( getattr( self, 'server_url' ), getattr( self, 'private_token' ) )
        self._api.set_verbosity( getattr( self, 'verbose' ) )
        if getattr( self, 'skip_ssl_verification' ):
         self._api.skip_ssl_verification()

        sys.exit( args.func( args ) )

# commands 
Example 36
Project: poetrify   Author: kk6   File: commands.py    MIT License 4 votes vote down vote up
def handle(self):
        workspace = self._determine_workspace(self.option("workspace"))
        os.chdir(workspace)

        _src = self.option("src")
        src = workspace.cwd() / _src
        poetry_command = build_poetry_init_command(src)
        if not poetry_command:
            self.line_error("[ERROR] Source file not found.", style="error")
            sys.exit(errno.ENOENT)

        self.info("Generated init command:")
        self.line(f"\n{poetry_command}\n")
        self.line("")

        if self.option("dry-run"):
            sys.exit(os.EX_OK)

        self.info(
            "Execute the above command. Also, the following output is due to Poetry."
        )

        r = subprocess.run(poetry_command, shell=True)
        if r.returncode != os.EX_OK:
            sys.exit(r.returncode)

        if self.confirm(f"Do you wanna delete {src.name}?", False):
            try:
                os.remove(src)
                self.info(f"{src.name} deleted!")
            except FileNotFoundError:
                self.line_error(f"{src.name} is not exists.", style="error")

        if src.name != "Pipfile":
            sys.exit(os.EX_OK)

        lock_file = src.parent / "Pipfile.lock"
        if self.confirm("Do you wanna delete Pipfile.lock?", False):
            try:
                os.remove(lock_file)
                self.info("Pipfile.lock deleted!")
            except FileNotFoundError:
                self.line_error("Pipfile.lock is not exists.", style="error") 
Example 37
Project: python-tldp   Author: tLDP   File: driver.py    MIT License 4 votes vote down vote up
def handleArgs(config, args):

    if config.doctypes:
        return show_doctypes(config, *args)

    if config.statustypes:
        return show_statustypes(config, *args)

    if config.summary:
        return summary(config, *args)

    docs, error = collectWorkset(config, args)

    if error:
        return error

    if not docs:
        logger.info("No work to do.")
        return os.EX_OK

    if config.detail:
        return detail(config, docs)

    # -- build(), script() and publish() will not be able to deal
    #    with orphans or with unknown source document types
    #
    docs = removeUnknownDoctypes(removeOrphans(docs))

    if config.script:
        return script(config, docs)

    if config.publish:
        return publish(config, docs)

    if not config.build:
        logger.info("Assuming --build, since no other action was specified...")
        config.build = True

    if config.build:
        return build(config, docs)

    return "Fell through handleArgs(); programming error."