示例#1
0
def add_package():
    name = request.forms.get("add_name", "New Package").strip()
    queue = int(request.forms['add_dest'])
    links = decode(request.forms['add_links'])
    links = links.split("\n")
    pw = request.forms.get("add_password", "").strip("\n\r")

    try:
        f = request.files['add_file']

        if not name or name == "New Package":
            name = f.name

        fpath = join(PYLOAD.getConfigValue("general", "download_folder"), "tmp_" + f.filename)
        destination = open(fpath, 'wb')
        copyfileobj(f.file, destination)
        destination.close()
        links.insert(0, fpath)
    except:
        pass

    name = name.decode("utf8", "ignore")

    links = map(lambda x: x.strip(), links)
    links = filter(lambda x: x != "", links)

    pack = PYLOAD.addPackage(name, links, queue)
    if pw:
        pw = pw.decode("utf8", "ignore")
        data = {"password": pw}
        PYLOAD.setPackageData(pack, data)
示例#2
0
def save_config(category):
    for key, value in request.POST.iteritems():
        try:
            section, option = key.split("|")
        except:
            continue

        if category == "general": category = "core"

        PYLOAD.setConfigValue(section, option, decode(value), category)
示例#3
0
文件: MultiHook.py 项目: kurtiss/htpc
    def _pluginSet(self, plugins):
        regexp  = re.compile(r'^[\w\-.^_]{3,63}\.[a-zA-Z]{2,}$', re.U)
        plugins = [decode(p.strip()).lower() for p in plugins if regexp.match(p.strip())]

        for r in self.DOMAIN_REPLACEMENTS:
            rf, rt  = r
            repr    = re.compile(rf, re.I|re.U)
            plugins = [re.sub(rf, rt, p) if repr.match(p) else p for p in plugins]

        return set(plugins)
示例#4
0
    def decryptAttr(self, data, key):
        k, iv, meta_mac = self.getCipherKey(key)
        cbc             = AES.new(k, AES.MODE_CBC, "\0" * 16)
        attr            = decode(cbc.decrypt(self.b64_decode(data)))

        self.logDebug("Decrypted Attr: %s" % attr)
        if not attr.startswith("MEGA"):
            self.fail(_("Decryption failed"))

        # Data is padded, 0-bytes must be stripped
        return json_loads(re.search(r'{.+?}', attr).group(0))
示例#5
0
    def decrypt_attr(self, data, key):
        k, iv, meta_mac = self.get_cipher_key(key)
        cbc             = AES.new(k, AES.MODE_CBC, "\0" * 16)
        attr            = decode(cbc.decrypt(self.b64_decode(data)))

        self.log_debug("Decrypted Attr: %s" % attr)
        if not attr.startswith("MEGA"):
            self.fail(_("Decryption failed"))

        #: Data is padded, 0-bytes must be stripped
        return json_loads(re.search(r'{.+?}', attr).group(0))
示例#6
0
    def _pluginSet(self, plugins):
        regexp = re.compile(r'^[\w\-.^_]{3,63}\.[a-zA-Z]{2,}$', re.U)
        plugins = [
            decode(p.strip()).lower() for p in plugins
            if regexp.match(p.strip())
        ]

        for r in self.DOMAIN_REPLACEMENTS:
            rf, rt = r
            repr = re.compile(rf, re.I | re.U)
            plugins = [
                re.sub(rf, rt, p) if repr.match(p) else p for p in plugins
            ]

        return set(plugins)
示例#7
0
def load_config(category, section):
    conf = None
    if category == "general":
        conf = PYLOAD.getConfigDict()
    elif category == "plugin":
        conf = PYLOAD.getPluginConfigDict()

    for key, option in conf[section].iteritems():
        if key in ("desc","outline"): continue

        if ";" in option["type"]:
            option["list"] = option["type"].split(";")

        option["value"] = decode(option["value"])

    return render_to_response("settings_item.html", {"skey": section, "section": conf[section]})
示例#8
0
    def renderFooter(self, line):
        """ prints out the input line with input """
        println(line, "")
        line += 1

        println(line, white(" Input: ") + decode(self.input))

        #clear old output
        if line < self.lastLowestLine:
            for i in range(line + 1, self.lastLowestLine + 1):
                println(i, "")

        self.lastLowestLine = line

        #set cursor to position
        print "\033[" + str(self.inputline) + ";0H"
示例#9
0
    def _log(self, level, *args, **kwargs):
        if "sep" in kwargs:
            sep = "%s" % kwargs["sep"]
        else:
            sep = " | "

        strings = []
        for obj in args:
            if type(obj) == unicode:
                strings.append(obj)
            elif type(obj) == str:
                strings.append(decode(obj))
            else:
                strings.append(str(obj))

        getattr(self.log, level)("%s: %s" % (self.__name__, sep.join(strings)))
示例#10
0
    def renderFooter(self, line):
        """ prints out the input line with input """
        println(line, "")
        line += 1

        println(line, white(" Input: ") + decode(self.input))

        #clear old output
        if line < self.lastLowestLine:
            for i in range(line + 1, self.lastLowestLine + 1):
                println(i, "")

        self.lastLowestLine = line

        #set cursor to position
        print "\033[" + str(self.inputline) + ";0H"
示例#11
0
    def _log(self, level, *args, **kwargs):
        if "sep" in kwargs:
            sep = "%s" % kwargs["sep"]
        else:
            sep = " | "

        strings = []
        for obj in args:
            if type(obj) == unicode:
                strings.append(obj)
            elif type(obj) == str:
                strings.append(decode(obj))
            else:
                strings.append(str(obj))

        getattr(self.log, level)("%s: %s" % (self.__name__, sep.join(strings)))
示例#12
0
文件: UnRar.py 项目: 3DMeny/pyload
    def listContent(self):
        command = "vb" if self.fullpath else "lb"
        p = self.call_unrar(command, "-v", self.file, password=self.password)
        out, err = p.communicate()

        if "Cannot open" in err:
            raise ArchiveError("Cannot open file")

        if err.strip():  #: only log error at this point
            self.m.logError(err.strip())

        result = set()

        for f in decode(out).splitlines():
            f = f.strip()
            result.add(save_join(self.out, f))

        self.files = result
示例#13
0
文件: UnRar.py 项目: sraedler/pyload
    def listContent(self):
        command = "vb" if self.fullpath else "lb"
        p = self.call_unrar(command, "-v", self.file, password=self.password)
        out, err = p.communicate()

        if "Cannot open" in err:
            raise ArchiveError("Cannot open file")

        if err.strip():  #: only log error at this point
            self.m.logError(err.strip())

        result = set()

        for f in decode(out).splitlines():
            f = f.strip()
            result.add(save_join(self.out, f))

        self.files = result
示例#14
0
 def parsePackages(self, startNode):
     return [(decode(node.getAttribute("name")).decode('base64'), self.parseLinks(node)) \
             for node in startNode.getElementsByTagName("package")]
示例#15
0
文件: DLC.py 项目: kurtiss/htpc
 def parsePackages(self, startNode):
     return [(decode(node.getAttribute("name")).decode('base64'), self.parseLinks(node)) \
             for node in startNode.getElementsByTagName("package")]