10 examples of 'python create dir' in Python

Every line of 'python create dir' 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
this disclaimer
30def create_dir(path):
31 """Create supplied directory"""
32 command = ["mkdir", "-p", path]
33 subprocess.Popen(command).communicate()
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

139def create_dir(dirname):
140 if not os.path.exists(os.path.expanduser(dirname)):
141 try:
142 os.makedirs(os.path.expanduser(dirname))
143 except (IOError, OSError):
144 pass
9def create_dir(name):
10 if not Path.exists(name):
11 Path.mkdir(name)
16def createdirectory(dirpath):
17 # we don't use os.mkdir/chown because we need sudo
18 command = ['/bin/mkdir', '-p', dirpath]
19 retcode, out, err = utils.execCmd(command, sudo=True, raw=True)
20 if retcode != 0:
21 sys.stderr.write('directlun: error mkdir %s, err = %s\n' % (dirpath, err))
22 sys.exit(2)
23
24 mode = '755'
25 command = ['/bin/chmod', mode, dirpath]
26 if retcode != 0:
27 sys.stderr.write('directlun: error chmod %s %s, err = %s\n' % (dirpath, mode, err))
28 sys.exit(2)
43def _create_dir(parent: Path, name: str, mode: int) -> Path:
44 p = Path(parent, name)
45 p.mkdir()
46 p.chmod(mode)
47 return p
52def create_dir(path):
53 if not os.path.exists(path):
54 try:
55 print("Attempting to create directory %s.\n" % path)
56 os.makedirs(path)
57 except OSError as exc:
58 if exc.errno != errno.EEXIST:
59 raise
74def recursiveCreateDir(dir):
75 o.debug("Creating destination {}".format(dir))
76 if not config.testMode:
77 if not os.path.exists(dir):
78 try:
79 os.makedirs(dir)
80 except OSError as e:
81 if e.errno != errno.EEXIST:
82 o.error('Unable to create {}'.format(dir))
4def create_dir(directory):
5 if not os.path.exists(directory):
6 os.makedirs(directory)
12def make_dir(base_dir, name):
13 """Make new dir into base dir, return concatenation"""
14 if path.exists(base_dir) and path.isdir(base_dir):
15 directory = path.join(base_dir, name)
16 if path.exists(directory) and path.isdir(directory):
17 #raise RuntimeError("Directory already exists: {}".format(directory))
18 return directory
19 else:
20 makedirs(directory)
21 return directory
22 else:
23 raise RuntimeError("Directory does not exist: {}".format(base_dir))
19def _create_directories(self):
20 if not os.path.exists(DATA_DIR):
21 print('Creating directory:{0}'.format(DATA_DIR))
22 os.makedirs(DATA_DIR)
23
24 if not os.path.exists(DELGADO_DIR):
25 print('Creating directory:{0}'.format(DELGADO_DIR))
26 os.makedirs(DELGADO_DIR)
27
28 if not os.path.exists(EXPERIMENTS_TRAINED_MODELS_DIR):
29 print('Creating directory:{0}'.format(EXPERIMENTS_TRAINED_MODELS_DIR))
30 os.makedirs(EXPERIMENTS_TRAINED_MODELS_DIR)

Related snippets