Python os.mkdirs() Examples

The following are code examples for showing how to use os.mkdirs(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: bootloader_instrumentation_suite   Author: bx   File: frama_c.py    (license) View Source Project 7 votes vote down vote up
def execute_frama_c(self, main):
        if not os.path.islink(self.shortdest):
        #    print self.shortdest
        #    print self.patchdest
            os.symlink(self.patchdest, self.shortdest)
        if len(self.backupdir) > 0:
            if not os.path.isdir(self.backupdir):
                os.mkdirs(self.backupdir)

            [shutil.copyfile(f.pp_path,
                             os.path.join(self.backupdir,
                                          os.path.basename(f.pp_path)))
             for f in self.preprocessed_files]

        cmd = "%s %s %s %s %s" % (self.frama_c, self.paths(),
                                  self.frama_c_main_arg, main, self.frama_c_args)
        if self.execute:
            if self.verbose:
                print cmd
            self.get_cmd_results(cmd)
        else:
            print cmd
            print "\n" 
Example 2
Project: ChromiumXRefs   Author: karlinjf   File: file_cache.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, cache_dir=None, expiration_in_minutes=30):

    # Protects |self| but individual file objects in |store| are not
    # protected once its returned from |_file_for|.
    self.lock = threading.Lock()

    # Dictionary mapping a URL to a tuple containing a file object and a
    # timestamp. The timestamp notes the creation time.
    self.store = {}

    # Directory containing cache files. If |cache_dir| is None, then each
    # file is created independently using tempfile.TemporaryFile().
    self.cache_dir = cache_dir

    # Garbage collector timer.
    self.timer = threading.Timer(15 * 60, self.gc)
    self.timer.start()

    self.expiration = datetime.timedelta(minutes=expiration_in_minutes)

    if cache_dir and not os.path.exists(cache_dir):
      if not os.path.isabs(cache_dir):
        raise ValueError('|cache_dir| should be an absolute path')
      os.mkdirs(cache_dir) 
Example 3
Project: rawr   Author: al14s   File: rdp.py    (license) View Source Project 6 votes vote down vote up
def get_screenshot(ip, port, logdir):
    log._LOG_LEVEL = log.Level.ERROR
    app = QtGui.QApplication(sys.argv)

    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor

    try: os.mkdirs(logdir + "5_Reporting/images/")
    except: pass

    reactor.connectTCP(ip, int(port), RDPScreenShotFactory(
        reactor, app, 1200, 800, "%s/5_Reporting/images/rdp_%s_%s.jpg" % (logdir, ip, port), 7))

    try: reactor.runReturn(installSignalHandlers=0)
    except: pass
    app.exec_()

    return "%s/5_Reporting/images/rdp_%s_%s.jpg" % (logdir, ip, port) 
Example 4
Project: rawr   Author: al14s   File: rawr_meta.py    (license) View Source Project 6 votes vote down vote up
def decompress(self, fn):
        ret = {}
        doc = zipfile.ZipFile(fn)

        try:
            os.mkdirs('./tmp')
        except:
            pass

        doc.extractall('./tmp/')
        for item in doc.infolist():
            x = self.file_parse('./tmp/' + item.orig_filename)
            if len(x.keys()) > 1:
                del x['filename']
                ret = self.addto(ret, x)

            if item.orig_filename == 'meta.xml':
                ret = self.addto(ret, self.ooo_meta('./tmp/' + item.orig_filename))

            elif item.orig_filename in ('docProps/app.xml',
                                        'docProps/core.xml') or item.orig_filename.split('/')[-1] \
                    in ('sharedStrings.xml', 'document.xml'):
                ret = self.addto(ret, self.msoffice_meta('./tmp/' + item.orig_filename))

        return ret 
Example 5
Project: rawr   Author: al14s   File: functions.py    (license) View Source Project 6 votes vote down vote up
def write_to_csv(timestamp, target):
    try:
        x = [" "] * len(flist.split(","))

        for i, v in target.items():
            if type(v) == list:
                v = ' | '.join(v)

            if i.lower() in flist.lower().split(', '):  # matching up the columns with our values
                x[flist.lower().split(", ").index(i.lower())] = re.sub('[\n\r,]', '', safe_string(v).replace('"', '"'))

    except Exception, ex:
        output.put("\n  %s[!]%s Unable to parse host record:\n\t%s\n" % (TC.YELLOW, TC.END, str(ex)))

    try:
        if not os.path.isfile("3_Enumeration/rawr_%s_serverinfo.csv" % timestamp):
            try: os.mkdirs("3_Enumeration")
            except: pass
            open("3_Enumeration/rawr_%s_serverinfo.csv" % timestamp, 'w').write(flist)

        open("3_Enumeration/rawr_%s_serverinfo.csv" % timestamp, 'a').write('\n"%s"' % (str('","'.join(x))))

    except Exception, ex:
        output.put("\n  %s[!]%s Unable to write .csv:\n\t%s\n" % (TC.YELLOW, TC.END, str(ex))) 
Example 6
Project: brunnhilde   Author: timothyryanwalsh   File: test.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        super(SelfCleaningTestCase, self).setUp()

        # tempdir for brunnhilde outputs
        self.dest_tmpdir = tempfile.mkdtemp()
        if not os.path.isdir(self.dest_tmpdir):
            os.mkdirs(self.dest_tmpdir) 
Example 7
Project: nustack   Author: BookOwl   File: Path.py    (license) View Source Project 5 votes vote down vote up
def make_dirs(env) -> "(path -- )":
    "Creates the directory given by path. Like make.dir, but makes all intermediate-level directories needed to contain the leaf directory"
    os.mkdirs(env.stack.pop().val) 
Example 8
Project: cca-diskimageprocessor   Author: timothyryanwalsh   File: test.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        super(SelfCleaningTestCase, self).setUp()

        # tempdir for brunnhilde outputs
        self.dest_tmpdir = tempfile.mkdtemp()
        if not os.path.isdir(self.dest_tmpdir):
            os.mkdirs(self.dest_tmpdir)