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


Python Io.set_data方法代码示例

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


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

示例1: save

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
 def save(self,path=None,notAssign=False):
     """"""
     path = path if path is not None else self.path
     Io.set_data(path, '# last updated : '+str(Sys.datetime.now())+Const.LF+self.toString())
     call = ' '.join(['python3', 'kirmah-cli.py', 'enc', '-qf', path, '-z', '-r', '-m', '-o', path+'.kmh', '-k', self.keyPath ])
     Sys.sysCall(call)
     Io.removeFile(path)
     if not notAssign : self.path = path
开发者ID:pluie-org,项目名称:imprastorage,代码行数:10,代码来源:ini.py

示例2: _saveLocalIndex

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
 def _saveLocalIndex(self):
     """"""
     if not self.idx : self._getId()
     if self.idx :
         msg     = self.ih.getEmail(self.idx, True)
         content = b''
         for part in msg.walk():
             content += part.get_payload(decode=True)
         Io.set_data(self.pathIdx, a2b_base64(content), True)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:11,代码来源:index.py

示例3: createDefaultKeyIfNone

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
 def createDefaultKeyIfNone(self):
     """"""
     kpath = self.getDefaultKeyPath()
     if not Io.file_exists(kpath):
         if Sys.isUnix():
             if not Sys.isdir(conf.DEFVAL_UKEY_PATH):
                 Sys.mkdir_p(conf.DEFVAL_UKEY_PATH)
                 Io.set_data(kpath, KeyGen(conf.DEFVAL_UKEY_LENGHT).key)
     self.selectKey(kpath)
开发者ID:necrose99,项目名称:Kirmah,代码行数:11,代码来源:app.py

示例4: encrypt

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_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

示例5: createDefaultKeyIfNone

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
 def createDefaultKeyIfNone(self):
     """"""
     kpath = self.getDefaultKeyPath()
     if not Io.file_exists(kpath):
         #if Sys.isUnix() :
             if not Sys.isdir(conf.DEFVAL_UKEY_PATH) :
                 Sys.mkdir_p(conf.DEFVAL_UKEY_PATH)
             k = KeyGen(conf.DEFVAL_UKEY_LENGHT)
             print(k)
             content = k.key
             print('content')
             Io.set_data(kpath, content)
             print('set content')
     self.selectKey(kpath)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:16,代码来源:app.py

示例6: __init__

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
 def __init__(self, path, keyPath=None):
     """"""
     self.path    = path
     self.dic     = {}
     self.keyPath = path+'.key' if keyPath is None else keyPath
     if not Io.file_exists(self.keyPath) :
         kg = KeyGen()
         Io.set_data(self.keyPath, kg.key)            
         if not Io.file_exists(path) :                
             self.set('profile'  , 'default', 'main')
             self.set('key'  ,kg.key,'default.keys')
             self.set('mark' ,kg.mark,'default.keys')
             self.set('salt' ,'-*-ImpraStorage-*-','default.keys')
             self.save()
     self.read()
开发者ID:pluie-org,项目名称:imprastorage,代码行数:17,代码来源:ini.py

示例7: onCommandExport

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
    def onCommandExport(self):
        """"""
        Sys.clear()
        self.pheader()
        from time import strftime

        name = strftime("%Y%m%d%H%M%S") + "_" + self.impst.idxu.conf.profile
        Sys.echo(" saving ", Sys.Clz.fgn7, False)
        Sys.echo(name + ".index" + Kirmah.EXT, Sys.Clz.fgB2)
        Io.copy(self.impst.idxu.pathIdx, name + ".index" + Kirmah.EXT)
        Sys.echo(" saving ", Sys.Clz.fgn7, False)
        Sys.echo(name + ".ini" + Kirmah.EXT, Sys.Clz.fgB2)
        self.impst.idxu.conf.ini.save(name + ".ini", True)
        Sys.echo(" saving ", Sys.Clz.fgn7, False)
        Sys.echo(name + ".key", Sys.Clz.fgB2)
        Io.set_data(name + ".key", self.impst.idxu.conf.get("key", "keys"))
        Sys.dprint("\n ", end="")
        Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
        Sys.dprint()
开发者ID:pluie-org,项目名称:imprastorage,代码行数:21,代码来源:cliapp.py

示例8: __init__

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
    def __init__(self, home, path, parser, Cli, a, o):
        """"""
        self.parser = parser
        self.Cli = Cli
        self.a = a
        self.o = o
        self.home = home
        self.stime = Sys.datetime.now()
        self.account = "default"
        self.rootBox = "__impra__2"
        self.uid = "0"
        self.date = ""
        if not Io.file_exists("impra2.ini" + Kirmah.EXT):
            print("ini file not exist")
            if len(self.a) > 0 and self.a[0] == "conf" and self.o.save:
                kg = KeyGen()
                Io.set_data("impra2.ini.key", kg.key)
                self.ini = KiniFile("impra2.ini")
                self.ini.set("key", kg.key, self.account + ".keys")
                self.ini.set("mark", kg.mark, self.account + ".keys")
                self.ini.set("salt", "-¤-ImpraStorage-¤-", self.account + ".keys")
            else:
                self.needConfig()

        else:
            if not (len(self.a) > 0 and self.a[0] == "conf"):
                self.ini = KiniFile("impra2.ini")
                self.impst = ImpraStorage(ImpraConf(self.ini), wkdir=path)
                self.uid = self.impst.idxu.conf.get("uid", "index")
                self.date = self.impst.idxu.conf.get("date", "index")
                self.account = self.impst.idxu.conf.get("user", "imap")
                self.rootBox = self.impst.rootBox
                if self.impst.idxu.index != None:
                    noData = self.impst.idxu.index.isEmpty()
                    if self.uid == None or noData:
                        self.uid = "EMPTY"
                    if self.date == None or noData:
                        self.date = ""
            else:
                self.ini = KiniFile("impra2.ini")
开发者ID:pluie-org,项目名称:imprastorage,代码行数:42,代码来源:cliapp.py

示例9: backupAddMap

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

示例10: __init__

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_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

示例11: onCommandKey

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
    def onCommandKey(self):
        """"""
        if int(self.o.length) >= 128 and int(self.o.length) <= 4096 :
            self.parser.print_header()
            if not self.o.outputfile : self.o.outputfile = self.home+'.kirmah'+Sys.sep+'.default.key'
            kg   = KeyGen(int(self.o.length))
            done = True
            if Io.file_exists(self.o.outputfile) and not self.o.force :

                Sys.pwarn((('the key file ',(self.o.outputfile, Sys.Clz.fgb3), ' already exists !'),
                           'if you rewrite this file, all previous files encrypted with the corresponding key will be unrecoverable !'))

                done   = Sys.pask('Are you sure to rewrite this file')
                self.stime  = Sys.datetime.now()
            if done :
                Io.set_data(self.o.outputfile, kg.key)
            Sys.pstep('Generate key file', self.stime, done)

            if done :
                Sys.print(' '*5+Sys.realpath(self.o.outputfile), Sys.Clz.fgB1, True)

        else :
            self.parser.error_cmd((('invalid option ',('-l, --length', Sys.Clz.fgb3), ' value (', ('128',Sys.Clz.fgb3),' to ', ('4096',Sys.Clz.fgb3),')'),))
开发者ID:necrose99,项目名称:Kirmah,代码行数:25,代码来源:cliapp.py

示例12: createNewKey

# 需要导入模块: from psr.sys import Io [as 别名]
# 或者: from psr.sys.Io import set_data [as 别名]
 def createNewKey(self, filename, size):
     """"""
     if not Sys.isdir(Sys.dirname(filename)):
         Sys.mkdir_p(Sys.dirname(filename))
     Io.set_data(filename,KeyGen(size).key[:size])
开发者ID:pluie-org,项目名称:imprastorage,代码行数:7,代码来源:app.py


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