本文整理汇总了Python中tools.mkdir函数的典型用法代码示例。如果您正苦于以下问题:Python mkdir函数的具体用法?Python mkdir怎么用?Python mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initPHPUnit
def initPHPUnit(self, force=False):
"""Initialise the PHPUnit environment"""
if self.branch_compare(23, '<'):
raise Exception('PHPUnit is only available from Moodle 2.3')
# Set PHPUnit data root
phpunit_dataroot = self.get('dataroot') + '_phpu'
self.updateConfig('phpunit_dataroot', phpunit_dataroot)
if not os.path.isdir(phpunit_dataroot):
mkdir(phpunit_dataroot, 0777)
# Set PHPUnit prefix
phpunit_prefix = 'phpu_'
self.updateConfig('phpunit_prefix', phpunit_prefix)
result = (None, None, None)
exception = None
try:
if force:
result = self.cli('/admin/tool/phpunit/cli/util.php', args='--drop', stdout=None, stderr=None)
result = self.cli('/admin/tool/phpunit/cli/init.php', stdout=None, stderr=None)
except Exception as exception:
pass
if exception != None or result[0] > 0:
if result[0] == 129:
raise Exception('PHPUnit is not installed on your system')
elif result[0] > 0:
raise Exception('Something wrong with PHPUnit configuration')
else:
raise exception
示例2: run
def run(RUN_TRAIN, RUN_TEST, RUN_TRAIN2, RUN_TEST2, RUN_SAVE):
tools.mkdir()
if RUN_TRAIN : trainer()
if RUN_TEST : tester()
if RUN_TRAIN2 : trainer(type_=2)
if RUN_TEST2 : tester(type_=2)
if RUN_SAVE: tools.saver()
示例3: link_swig
def link_swig(source):
target = os.path.join("swig")
tools.mkdir(target)
for module, g in tools.get_modules(source):
# they all go in the same dir, so don't remove old links
tools.link_dir(
os.path.join(g,
"pyext"),
target,
match=["*.i"],
clean=False)
if os.path.exists(os.path.join(g, "pyext", "include")):
tools.link_dir(
os.path.join(g,
"pyext",
"include"),
target,
match=["*.i"],
clean=False)
tools.link(
os.path.join(
g,
"pyext",
"swig.i-in"),
os.path.join(
target,
"IMP_%s.impl.i" %
module))
示例4: main
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
mkdir(settings['static_files'])
# Create Ziggurat tables
alembic_ini_file = 'alembic.ini'
if not os.path.exists(alembic_ini_file):
alembic_ini = ALEMBIC_CONF.replace('{{db_url}}',
settings['sqlalchemy.url'])
f = open(alembic_ini_file, 'w')
f.write(alembic_ini)
f.close()
bin_path = os.path.split(sys.executable)[0]
alembic_bin = os.path.join(bin_path, 'alembic')
command = '%s upgrade head' % alembic_bin
os.system(command)
os.remove(alembic_ini_file)
# Insert data
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
init_model()
create_schemas(engine)
Base.metadata.create_all(engine)
initial_data.insert()
transaction.commit()
示例5: generate_all_cpp
def generate_all_cpp(source):
target=os.path.join("src")
tools.mkdir(target)
for module, g in tools.get_modules(source):
sources= tools.get_glob([os.path.join(g, "src", "*.cpp")])\
+tools.get_glob([os.path.join(g, "src", "internal", "*.cpp")])
targetf=os.path.join(target, module+"_all.cpp")
sources.sort()
tools.rewrite(targetf, "\n".join(["#include <%s>"%os.path.abspath(s) for s in sources]) + '\n')
示例6: run
def run(RUN_TRAIN, RUN_TEST, RUN_TRAIN2, RUN_TEST2, RUN_SAVE):
tools.mkdir()
if RUN_TRAIN : trainer()
if RUN_TEST : tester()
if RUN_TRAIN2 : trainer(type_=2)
if RUN_TEST2 : tester(type_=2)
if RUN_SAVE: tools.saver()
if RUN_DENSECRF : crf_runner(LOAD_MAT_FILE, RUN_TRAIN2)
if GRID_SEARCH : grid_search(LOAD_MAT_FILE, RUN_TRAIN2)
示例7: main
def main():
(options, args) = parser.parse_args()
outputdir= os.path.abspath(os.path.join("src", "%s_swig"%options.module))
tools.mkdir(outputdir, clean=False)
run_swig(outputdir, options)
patch_file(os.path.join(outputdir, "wrap.cpp-in"),
os.path.join(outputdir, "wrap.cpp"), options)
patch_file(os.path.join(outputdir, "wrap.h-in"),
os.path.join(outputdir, "wrap.h"), options)
示例8: test_mkdir
def test_mkdir(self):
self.assertFalse(tools.mkdir('/'))
with TemporaryDirectory() as d:
path = os.path.join(d, 'foo')
self.assertTrue(tools.mkdir(path))
for mode in (0o700, 0o644, 0o777):
msg = 'new path should have octal permissions {0:#o}'.format(mode)
path = os.path.join(d, '{0:#o}'.format(mode))
self.assertTrue(tools.mkdir(path, mode), msg)
self.assertEqual('{0:o}'.format(os.stat(path).st_mode & 0o777), '{0:o}'.format(mode), msg)
示例9: link_dox
def link_dox(source):
for subdir in ("ref", "manual"):
target = os.path.join("doxygen", subdir)
tools.mkdir(target)
tools.link_dir(os.path.join(source, "doc", "ref"),
os.path.join("doc", "ref"),
match=["*.png", "*.pdf", "*.gif"], clean=False)
tools.link_dir(os.path.join(source, "doc", "manual", "images"),
os.path.join("doc", "manual"),
match=["*.png", "*.pdf", "*.gif"], clean=False)
示例10: link_dox
def link_dox(source):
target = os.path.join("doxygen")
tools.mkdir(target)
for module, g in tools.get_modules(source):
tools.link_dir(os.path.join(g, "doc"),
os.path.join("doc", "html", module),
match=["*.png", "*.pdf", "*.gif"], clean=False)
tools.link_dir(os.path.join(source, "doc"), os.path.join("doc", "html"),
match=["*.png", "*.pdf", "*.gif"], clean=False)
tools.link_dir(os.path.join(source, "doc", "tutorial"),
os.path.join("doc", "tutorial"),
match=["*.png", "*.pdf", "*.gif"], clean=False)
示例11: link_python
def link_python(source):
target=os.path.join("lib")
tools.mkdir(target, clean=False)
for module, g in tools.get_modules(source):
path= os.path.join(target, "IMP", module)
tools.mkdir(path, clean=False)
for old in tools.get_glob([os.path.join(path, "*.py")]):
# don't unlink the generated file
if os.path.split(old)[1] != "__init__.py" and os.path.split(old)[1] != "_version_check.py":
os.unlink(old)
#print "linking", path
tools.link_dir(os.path.join(g, "pyext", "src"), path, clean=False)
示例12: link_headers
def link_headers(source):
target=os.path.join("include")
tools.mkdir(target)
root=os.path.join(target, "IMP")
tools.mkdir(root)
for (module, g) in tools.get_modules(source):
#print g, module
if module== "SConscript":
continue
tools.link_dir(os.path.join(g, "include"), os.path.join(root, module), match=["*.h"])
tools.link_dir(os.path.join(g, "include", "internal"), os.path.join(root, module, "internal"),
match=["*.h"])
示例13: link_benchmark
def link_benchmark(options):
path = os.path.join("benchmark", options.name)
tools.mkdir(path, clean=False)
for old in tools.get_glob([os.path.join(path, "*.py")]):
os.unlink(old)
tools.link_dir(
os.path.join(options.source,
"modules",
options.name,
"benchmark"),
path,
clean=False,
match=["*.py"])
示例14: make_version_check
def make_version_check(options):
dir= os.path.join("lib", "IMP", options.name)
tools.mkdir(dir, clean=False)
outf= os.path.join(dir, "_version_check.py")
template="""def check_version(myversion):
def _check_one(name, expected, found):
if expected != found:
raise RuntimeError('Expected version '+expected+' but got '+ found \
+' when loading module '+name\
+'. Please make sure IMP is properly built and installed and that matching python and C++ libraries are used.')
_check_one('%s', '%s', myversion)
"""
tools.rewrite(outf, template%(options.name, get_version(options)))
示例15: make_version_check
def make_version_check(options):
dir= os.path.join("lib", "IMP", options.name)
tools.mkdir(dir, clean=False)
version = tools.get_module_version(options.name, options.source)
outf= os.path.join(dir, "_version_check.py")
template="""def check_version(myversion):
def _check_one(name, expected, found):
if expected != found:
message = "Expected version " + expected + " but got " + found + " when loading module " + name + ". Please make sure IMP is properly built and installed and that matching python and C++ libraries are used."
raise RuntimeError(message)
version = '%s'
_check_one('%s', version, myversion)
"""
tools.rewrite(outf, template%(version, version))