Python uos.mkdir() Examples
The following are 5
code examples of uos.mkdir().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
uos
, or try the search function
.
Example #1
Source File: utils.py From UIFlow-Code with GNU General Public License v3.0 | 6 votes |
def makedirs(path): _path = '' if path[0] == '/': path = path.strip('/').split('/') for i in path: _path += '/' + i try: os.mkdir(_path) except: pass else: path = path.split('/') for i in path: _path += i try: os.mkdir(_path) _path += '/' except: pass
Example #2
Source File: files.py From ampy with MIT License | 5 votes |
def mkdir(self, directory, exists_okay=False): """Create the specified directory. Note this cannot create a recursive hierarchy of directories, instead each one should be created separately. """ # Execute os.mkdir command on the board. command = """ try: import os except ImportError: import uos as os os.mkdir('{0}') """.format( directory ) self._pyboard.enter_raw_repl() try: out = self._pyboard.exec_(textwrap.dedent(command)) except PyboardError as ex: # Check if this is an OSError #17, i.e. directory already exists. if ex.args[2].decode("utf-8").find("OSError: [Errno 17] EEXIST") != -1: if not exists_okay: raise DirectoryExistsError( "Directory already exists: {0}".format(directory) ) else: raise ex self._pyboard.exit_raw_repl()
Example #3
Source File: util.py From developer-badge-2018-apps with Apache License 2.0 | 5 votes |
def save(self): # Create config_dir if do not exists try: uos.stat(self.config_dir) except OSError: uos.mkdir(self.config_dir) with open('{}/{}.json'.format(self.config_dir, self.name), 'w') as fp: json.dump(self.data, fp)
Example #4
Source File: test_server.py From esp8266 with BSD 2-Clause "Simplified" License | 5 votes |
def mkdir(path): try: uos.mkdir(path) except OSError as e: pass
Example #5
Source File: test_server.py From esp8266 with BSD 2-Clause "Simplified" License | 5 votes |
def init(root_path='/test'): print("Initializing from {}...".format(root_path)) mkdir('{}'.format(root_path)) write('{}/index.html'.format(root_path), "<html><body>Hello World!</body></html>") mkdir('{}/foo'.format(root_path)) write('{}/foo/test.txt'.format(root_path), "test") mkdir('{}/foo/bar'.format(root_path)) write('{}/foo/bar/test.js'.format(root_path), "{'foo': \"bar\"}") write('{}/foo/bar/test.css'.format(root_path), "html")