Exemple #1
0
    def get_filepath(self, url, filetype):
        """Get full path and filename for the file"""

        typemap = {'avatar': self._images,
                   'file': self._files}

        if filetype == 'file' and not self._authorized:
            logging.warning("There was no (valid) credentials passed, "
                            "therefore file `%s' cannot be downloaded", url)
            return

        splitted = url.split('/')

        if len(splitted) == 7 and ('slack.com' in splitted[2] or
                                   'slack-edge.com' in splitted[2]):
            part = url.split('/')[-3]
            fname = url.split('/')[-1]
        else:
            logging.info("URL doesn't seem to be slack internal: %s", url)
            part = ''
            fname = splitted[-1]

        path = typemap[filetype]

        if part:
            utils.makedirs(os.path.join(path, part))
            path = os.path.join(path, part)

        return os.path.join(path, fname)
Exemple #2
0
    def prepare_filepath(self, url, filetype):
        """Prepare directory where to download file into"""

        typemap = {'avatar': self._images, 'file': self._files}

        if filetype == 'file' and not self._authorized:
            logging.warning(
                "There was no (valid) credentials passed, "
                "therefore file `%s' cannot be downloaded", url)
            return

        splitted = url.split('/')

        if len(splitted) == 7 and 'slack.com' in splitted[2]:
            part = url.split('/')[-3]
            fname = url.split('/')[-1]
        else:
            logging.info("URL doesn't seem to be slack internal: %s", url)
            part = ''
            fname = splitted[-1]

        path = typemap[filetype]

        if part:
            utils.makedirs(os.path.join(path, part))
            path = os.path.join(path, part)

        path = os.path.join(path, fname)
        count = 1

        while filetype != 'avatar' and os.path.exists(path):
            if count == 1:
                base, ext = os.path.splitext(path)
            path = base + ".%0.3d" % count + ext
            count += 1

        return path
Exemple #3
0
 def __init__(self, args, query):
     super(StaticHtmlReporter, self).__init__(args, query)
     utils.makedirs(self.out)
     self._max_len = 0
Exemple #4
0
    def _create_assets_dir(self):
        for path in (self._files, self._images):
            utils.makedirs(path)

        self._hier_created = True
Exemple #5
0
    def __init__(self, args, query):
        super(TextReporter, self).__init__(args, query)
        utils.makedirs(self.out)
        self._max_len = 0

        return