当前位置: 首页>>代码示例>>Python>>正文


Python Io.get_data方法代码示例

本文整理汇总了Python中psr.sys.Io.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python Io.get_data方法的具体用法?Python Io.get_data怎么用?Python Io.get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psr.sys.Io的用法示例。


在下文中一共展示了Io.get_data方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getBackupAddMap

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
 def getBackupAddMap(self):
     """"""
     data = None
     if Io.file_exists(self.addmapPath + Kirmah.EXT):
         call = " ".join(
             [
                 Sys.executable,
                 "kirmah-cli.py",
                 "dec",
                 "-qf",
                 self.addmapPath + Kirmah.EXT,
                 "-z",
                 "-r",
                 "-m",
                 "-o",
                 self.addmapPath,
                 "-k",
                 self.idxu.index.keyPath,
             ]
         )
         print(call)
         Sys.sysCall(call)
         data = jloads(Io.get_data(self.addmapPath))
         Io.removeFile(self.addmapPath)
     return data
开发者ID:pluie-org,项目名称:imprastorage,代码行数:27,代码来源:core.py

示例2: onCommandDec

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
    def onCommandDec(self):
        """"""
        done  = True
        if self.o.outputfile is None :
            self.o.outputfile = self.a[1][:-4] if self.a[1][-4:] == Kirmah.EXT else self.a[1]

        if not Sys.g.QUIET : self.parser.print_header()

        if Io.file_exists(self.o.outputfile) and not self.o.force:
            Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),))
            done  = Sys.pask('Are you sure to rewrite this file')
            self.stime = Sys.datetime.now()

        if done :

            try :

                if (self.o.multiprocess is not None and not represents_int(self.o.multiprocess)) or (not self.o.multiprocess is None and not(int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8)) :
                    self.parser.error_cmd((('invalid option ',('-j, --multiprocess', Sys.Clz.fgb3), ' value (', ('2',Sys.Clz.fgb3),' to ', ('8',Sys.Clz.fgb3),')'),))

                nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1

                Sys.ptask()

                key    = Io.get_data(self.o.keyfile)
                km     = Kirmah(key)

                km.decrypt(self.a[1], self.o.outputfile, nproc)

            except BadKeyException:
                done = False
                Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)

        if not Sys.g.QUIET :
            self.onend_cmd('Kirmah Decrypt', self.stime, done, self.o.outputfile)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:37,代码来源:cliapp.py

示例3: buildIndex

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
 def buildIndex(self, fromPath):
     """Build mail for ImpraIndex
     :Returns: 'email.message.Message'
     """
     msg = MIMEText(Io.str(b2a_base64(Io.get_data(fromPath, True))), 'plain', 'utf-8')
     msg['From']    = self.getHashName('system')+'@'+self.DOMAIN_NAME
     msg['To']      = self.getHashName('all')+'@'+self.DOMAIN_NAME
     msg['Date']    = formatdate(localtime=True)
     msg['Subject'] = Header(self.getHashName('index'),'utf-8')      
     return msg
开发者ID:pluie-org,项目名称:imprastorage,代码行数:12,代码来源:mail.py

示例4: getKeyInfos

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
 def getKeyInfos(self, filename=None):
     """"""
     if filename is None:
         filename = self.getDefaultKeyPath()
     if not Io.file_exists(filename):
         raise FileNotFoundException(filename)
     k = Io.get_data(filename)
     s = len(k)
     m = KeyGen(s).getMark(k)
     return k, s, m
开发者ID:necrose99,项目名称:Kirmah,代码行数:12,代码来源:app.py

示例5: encrypt

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
 def encrypt(self, fromPath=None):
     """"""
     if fromPath is None :
         fromPath = self.pathPlain
     Sys.pwlog([(' Encrypt Index... ' , Const.CLZ_0, True)])
     Io.set_data(fromPath, jdumps(self.dic))        
     call = ' '.join([Sys.executable, 'kirmah-cli.py', 'enc', '-qfj2' if Sys.isUnix() else '-qf', fromPath, '-z', '-r', '-m', '-o', fromPath+Kirmah.EXT, '-k', self.keyPath ])
     #~ print(call)
     Sys.sysCall(call)
     Io.removeFile(fromPath)
     Sys.pwlog([(' done', Const.CLZ_2, True)])   
     return Io.get_data(fromPath+Kirmah.EXT, True)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:14,代码来源:index.py

示例6: on_about

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
 def on_about(self, btn):
     """"""
     about = AboutDialog()
     about.set_program_name(conf.PRG_NAME)
     about.set_version("v " + conf.PRG_VERS)
     about.set_copyright(conf.PRG_ABOUT_COPYRIGHT)
     about.set_comments(conf.PRG_ABOUT_COMMENTS)
     about.set_website(conf.PRG_WEBSITE)
     about.set_website_label(conf.PRG_WEBSITE)
     about.set_license(Io.get_data(conf.PRG_LICENSE_PATH))
     pixbuf = Pixbuf.new_from_file_at_size(conf.PRG_LOGO_PATH, conf.PRG_ABOUT_LOGO_SIZE, conf.PRG_ABOUT_LOGO_SIZE)
     about.set_logo(pixbuf)
     pixbuf = Pixbuf.new_from_file_at_size(conf.PRG_LOGO_PATH, conf.PRG_ABOUT_LOGO_SIZE, conf.PRG_ABOUT_LOGO_SIZE)
     about.set_icon(pixbuf)
     about.run()
     about.destroy()
开发者ID:necrose99,项目名称:Kirmah,代码行数:18,代码来源:ui.py

示例7: onCommandEnc

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
    def onCommandEnc(self):
        """"""
        done   = True
        if self.o.outputfile is None :
            self.o.outputfile = Sys.basename(self.a[1])
        if self.o.outputfile[-len(Kirmah.EXT):] != Kirmah.EXT :
            print(self.o.outputfile[-len(Kirmah.EXT):])
            self.o.outputfile += Kirmah.EXT
        print(self.o.outputfile)

        d        = self.getDefaultOption((self.o.compress,self.o.fullcompress,self.o.nocompress))
        compress = (KirmahHeader.COMP_END if d == 0 or (d is None and Io.is_binary(self.a[1])) else (KirmahHeader.COMP_ALL if d==1 or d is None else KirmahHeader.COMP_NONE))
        random   = True if (self.o.random is None and self.o.norandom is None) or self.o.random else False
        mix      = True if (self.o.mix is None and self.o.nomix is None) or self.o.mix else False

        if (self.o.multiprocess is not None and not represents_int(self.o.multiprocess)) or (not self.o.multiprocess is None and not(int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8)) :
            self.parser.error_cmd((('invalid option ',('-j, --multiprocess', Sys.Clz.fgb3), ' value (', ('2',Sys.Clz.fgb3),' to ', ('8',Sys.Clz.fgb3),')'),))

        nproc = int(self.o.multiprocess) if not self.o.multiprocess is None and int(self.o.multiprocess)>=2 and int(self.o.multiprocess) <=8 else 1

        if not Sys.g.QUIET : self.parser.print_header()

        if Io.file_exists(self.o.outputfile) and not self.o.force:
            Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),))
            done  = Sys.pask('Are you sure to rewrite this file')
            self.stime = Sys.datetime.now()

        if done :

            try :
                Sys.ptask()

                key    = Io.get_data(self.o.keyfile)
                km     = Kirmah(key, None, compress, random, mix)

                km.encrypt(self.a[1], self.o.outputfile, nproc)

            except Exception as e :
                done = False
                print(e)
                raise e
                pass

        if not Sys.g.QUIET :
            self.onend_cmd('Kirmah Encrypt', self.stime, done, self.o.outputfile)
开发者ID:necrose99,项目名称:Kirmah,代码行数:47,代码来源:cliapp.py

示例8: decrypt

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
 def decrypt(self, fromPath=None):
     """"""        
     done = False
     try :
         if fromPath is None :
             fromPath = self.path
         toPath = fromPath[:-len(Kirmah.EXT)] if fromPath.endswith(Kirmah.EXT) else fromPath+'.dump'
         if Io.file_exists(fromPath) :
             Sys.pwlog([(' Decrypt Index... '                        , Const.CLZ_0, True)])
             call = ' '.join([Sys.executable, 'kirmah-cli.py', 'dec', '-qfj2' if Sys.isUnix() else '-qf', fromPath, '-z', '-r', '-m', '-o', toPath, '-k', self.keyPath ])
             print(call)
             Sys.sysCall(call)
             data   = jloads(Io.get_data(toPath))
             Io.removeFile(toPath)
         else :
             data = {}
         done = True
     except ValueError as e:
         raise BadKeyException(e)
     Sys.pwlog([(' done'if done else ' ko'    , Const.CLZ_2 if done else Const.CLZ_1, True)])
     return data
开发者ID:pluie-org,项目名称:imprastorage,代码行数:23,代码来源:index.py

示例9: __init__

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
    def __init__(self, key, path, dicCategory={}, accountList={}, emit=False):
        """Initialize the index with rsa and encoded data

        :Parameters:
            `key`     : str
                appropriate key to decrypt/encrypt data
            `mark`    : str
                appropriate mark to check correct key
            `encdata` : str
                initial content of the index encrypted with Kirmah Algorythm
                and representing a dic index as json string
        """
        self.pathPlain = path[:-len(Kirmah.EXT)]
        self.keyPath   = self.pathPlain+self.KEY_EXT
        self.path      = path
        Io.set_data(self.keyPath, key)
        self.dic       = {}
        self.acclist   = accountList
        encdata        = Io.get_data(path, True) if Io.file_exists(path) else b''

        if encdata == b'' :
            self.dic = {}
            self.id  = 1
        else :
            self.dic = self.decrypt(path)
            l        = [self.dic[k][self.UID] for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)]
            if len(l) > 0 :
                self.id = max(l)+1
            else: self.id = 1
        for k in dicCategory :
            if k == 'users' :
                for k1 in dicCategory[k]:
                    if self.SEP_KEY_INTERN+k in self.dic:
                        if k1 not in self.dic[self.SEP_KEY_INTERN+k]:
                            self.dic[self.SEP_KEY_INTERN+k][k1] = dicCategory[k][k1]
            else :
                if not self.SEP_KEY_INTERN+k in self.dic:
                    self.dic[self.SEP_KEY_INTERN+k] = dicCategory[k]
开发者ID:pluie-org,项目名称:imprastorage,代码行数:40,代码来源:index.py

示例10: onCommandMerge

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
    def onCommandMerge(self):
        """"""
        done   = True

        if not Sys.g.QUIET : self.parser.print_header()

        if done :
            toPath = None
            try :
                Sys.ptask()

                key    = Io.get_data(self.o.keyfile)
                km     = Kirmah(key)
                kcf    = None
                istar  = True
                try:
                    import tarfile
                    dpath = Sys.dirname(Sys.realpath(self.o.outputfile))+Sys.sep if self.o.outputfile is not None else Sys.dirname(Sys.realpath(self.a[1]))+Sys.sep
                    if self.o.outputfile is None :
                        self.o.outputfile = dpath
                    with tarfile.open(self.a[1], mode='r') as tar:
                        #~ print(dpath)
                        tar.extractall(path=dpath)
                        kcf = None
                        for tarinfo in tar:
                            #~ print(tarinfo.name)
                            if tarinfo.isreg() and tarinfo.name[-4:]=='.kcf':
                                #~ print(dpath+tarinfo.name)
                                kcf = dpath+tarinfo.name
                    if kcf is not None :
                        km.DIR_OUTBOX = dpath
                        toPath = km.mergeFile(kcf, self.o.outputfile)
                except BadKeyException:
                    Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
                    done = False

                except Exception :
                    istar  = False
                    toPath = km.mergeFile(self.a[1], self.o.outputfile)

                #~ if self.o.outputfile is not None :
                #~ Io.rename(toPath, self.o.outputfile)
                #~ toPath = self.o.outputfile

            except BadKeyException:
                Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
                done = False

            except Exception as e :
                done = False
                if Sys.g.DEBUG :
                    print(e)
                elif not Sys.g.QUIET :
                    Sys.pwarn((str(e),))
        if not done :
            if istar :
                with tarfile.open(self.a[1], mode='r') as tar:
                    for tarinfo in tar:
                        Sys.removeFile(dpath+tarinfo.name)

        if not Sys.g.QUIET :
            self.onend_cmd('Kirmah Merge', self.stime, done, toPath)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:64,代码来源:cliapp.py

示例11: onCommandSplit

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import get_data [as 别名]
    def onCommandSplit(self):
        """"""
        done  = True
        Sys.cli_emit_progress(1)
        if not self.o.parts is None and not(int(self.o.parts)>=12 and int(self.o.parts) <=62) :
            self.parser.error_cmd((('invalid option ',('-p, --parts', Sys.Clz.fgb3), ' value (', ('12',Sys.Clz.fgb3),' to ', ('62',Sys.Clz.fgb3),')'),))
        else : self.o.parts = int(self.o.parts)

        if not Sys.g.QUIET : self.parser.print_header()
        if self.o.outputfile is not None :
            if self.o.outputfile[-5:]!='.tark' : self.o.outputfile += '.tark'
            if Io.file_exists(self.o.outputfile) and not self.o.force:
                Sys.pwarn((('the file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),))
                done  = Sys.pask('Are you sure to rewrite this file')
                self.stime = Sys.datetime.now()

        if done :

            try :
                Sys.ptask()
                Sys.cli_emit_progress(2)
                key    = Io.get_data(self.o.keyfile)
                km     = Kirmah(key)
                hlst   = km.ck.getHashList(Sys.basename(self.a[1]), self.o.parts, True)
                Sys.cli_emit_progress(3)
                kcf    = km.splitFile(self.a[1], hlst)
                t      = int(Sys.time())
                times  = (t,t)
                p      = 85
                Sys.cli_emit_progress(p)
                Io.touch(kcf, times)
                frav = 0.24
                for row in hlst['data']:
                    p += frav
                    Io.touch(row[1]+km.EXT,times)
                    Sys.cli_emit_progress(p)
                if self.o.outputfile is not None :
                    d = Sys.datetime.now()
                    if Sys.g.DEBUG : Sys.wlog(Sys.dprint())
                    Sys.ptask('Preparing tark file')
                    hlst['data'] = sorted(hlst['data'], key=lambda lst: lst[4])
                    with tarfile.open(self.o.outputfile, mode='w') as tar:
                        tar.add(kcf, arcname=Sys.basename(kcf))
                        p    = 90
                        for row in hlst['data']:
                            tar.add(row[1]+km.EXT, arcname=Sys.basename(row[1]+km.EXT))
                            p += frav
                            Sys.cli_emit_progress(p)
                    Sys.pstep('Packing destination file', d, True)
                    d = Sys.datetime.now()
                    Sys.ptask('Finalize')
                    for row in hlst['data']:
                        Io.removeFile(row[1]+km.EXT)
                        p += frav
                        Sys.cli_emit_progress(p)
                    Io.removeFile(kcf)
                    Sys.pstep('Cleaning', d, True)

            except Exception as e :
                done = False
                if Sys.g.DEBUG :
                    print('split exception')
                    print(e)

                    #~ raise e
                elif not Sys.g.QUIET :
                    Sys.pwarn((str(e),))

        if not Sys.g.QUIET:
            Sys.cli_emit_progress(100)
            self.onend_cmd('Kirmah Split', self.stime, done, self.o.outputfile)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:73,代码来源:cliapp.py


注:本文中的psr.sys.Io.get_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。