7 examples of 'pcheck module in python' in Python

Every line of 'pcheck module in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
17def check_py():
18
19 if os_system() == "Windows":
20 try:
21 py_ver = subprocess.check_output(
22 "py -3 -V").decode('UTF-8').splitlines()[0]
23 print("Script has detected " + py_ver +
24 " version present on the machine.")
25 except:
26 print("Script could not detect Python 3 on the machine.\n"
27 "Go to https://www.python.org/downloads/ page and download latest Python 3 version.")
28 else:
29 try:
30 py_ver = subprocess.check_output(["python3", "-V"]).decode('UTF-8').splitlines()[0]
31 print("Script detected " + py_ver +
32 " version present on the machine.")
33 except:
34 print("Script could not detect Python 3 on the machine.\n"
35 "Go to https://www.python.org/downloads/ page and download latest Python 3 version.")
463@conf
464def check_python_module(conf, module_name, condition=''):
465 """
466 Check if the selected python interpreter can import the given python module::
467
468 def configure(conf):
469 conf.check_python_module('pygccxml')
470 conf.check_python_module('re', condition="ver > num(2, 0, 4) and ver <= num(3, 0, 0)")
471
472 :param module_name: module
473 :type module_name: string
474 """
475 msg = 'Python module %s' % module_name
476 if condition:
477 msg = '%s (%s)' % (msg, condition)
478 conf.start_msg(msg)
479 try:
480 ret = conf.cmd_and_log(conf.env['PYTHON'] + ['-c', PYTHON_MODULE_TEMPLATE % module_name])
481 except Exception:
482 conf.end_msg(False)
483 conf.fatal('Could not find the python module %r' % module_name)
484
485 ret = ret.strip()
486 if condition:
487 conf.end_msg(ret)
488 if ret == 'unknown version':
489 conf.fatal('Could not check the %s version' % module_name)
490
491 from distutils.version import LooseVersion
492 def num(*k):
493 if isinstance(k[0], int):
494 return LooseVersion('.'.join([str(x) for x in k]))
495 else:
496 return LooseVersion(k[0])
497 d = {'num': num, 'ver': LooseVersion(ret)}
498 ev = eval(condition, {}, d)
499 if not ev:
500 conf.fatal('The %s version does not satisfy the requirements' % module_name)
501 else:
502 if ret == 'unknown version':
503 conf.end_msg(True)
504 else:
505 conf.end_msg(ret)
6def check(p):
7 msg = p.msg
8 if msg != "hi there":
9 raise RuntimeError("Bad, got: " + msg)
78def module_is_in(pfiles, module):
79 """
80 Find the parsed file containing the desidered module.
81
82 Parameters
83 ----------
84 pfiles : list
85 list of parsed files
86 module : str
87 module name
88
89 Returns
90 -------
91 file_name : str
92 name of file containing the module
93 number : int
94 number of file containing the module
95 """
96 file_name = ""
97 number = -1
98 for fnum, parsed_file in enumerate(pfiles):
99 if parsed_file.module:
100 for module_name in parsed_file.module_names:
101 if module_name.lower() == module.lower():
102 file_name = parsed_file.name
103 number = fnum
104 break
105 return file_name, number
328def check(modname):
329 """Check if required dependency is installed"""
330 for dependency in DEPENDENCIES:
331 if dependency.modname == modname:
332 return dependency.check()
333 else:
334 raise RuntimeError("Unkwown dependency %s" % modname)
109def test_pypy(self):
110 self.assertEqual(0, self._execute_code('pypy'))
112def test_pypy3(self):
113 self.assertEqual(0, self._execute_code('pypy3'))

Related snippets