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


Python GLSecureTemporaryFile.avoid_delete方法代码示例

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


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

示例1: get_dummy_file

# 需要导入模块: from globaleaks.security import GLSecureTemporaryFile [as 别名]
# 或者: from globaleaks.security.GLSecureTemporaryFile import avoid_delete [as 别名]
    def get_dummy_file(self, filename=None, content_type=None, content=None):

        if filename is None:
            filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

        if content_type is None:
            content_type = 'application/octet'

        if content is None:
            content = "ANTANI"

        temporary_file = GLSecureTemporaryFile(GLSetting.tmp_upload_path)

        temporary_file.write(content)
        temporary_file.avoid_delete()

        dummy_file = {
            'body': temporary_file,
            'body_len': len(content),
            'body_filepath': temporary_file.filepath,
            'filename': filename,
            'content_type': content_type,
        }

        return dummy_file
开发者ID:globaleaks,项目名称:GLBackend-outdated,代码行数:27,代码来源:helpers.py

示例2: get_dummy_file

# 需要导入模块: from globaleaks.security import GLSecureTemporaryFile [as 别名]
# 或者: from globaleaks.security.GLSecureTemporaryFile import avoid_delete [as 别名]
    def get_dummy_file(self, filename=None, content_type=None, content=None):
        if filename is None:
            filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

        if content_type is None:
            content_type = 'application/octet'

        if content is None:
            content = 'LA VEDI LA SUPERCAZZOLA ? PREMATURA ? unicode €'

        temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

        temporary_file.write(content)
        temporary_file.avoid_delete()

        dummy_file = {
            'body': temporary_file,
            'body_len': len(content),
            'body_filepath': temporary_file.filepath,
            'filename': filename,
            'content_type': content_type,
            'submission': False
        }

        return dummy_file
开发者ID:corvolino,项目名称:GlobaLeaks,代码行数:27,代码来源:helpers.py

示例3: test_004_temporary_file_lost_key_due_to_eventual_bug_or_reboot

# 需要导入模块: from globaleaks.security import GLSecureTemporaryFile [as 别名]
# 或者: from globaleaks.security.GLSecureTemporaryFile import avoid_delete [as 别名]
 def test_004_temporary_file_lost_key_due_to_eventual_bug_or_reboot(self):
     a = GLSecureTemporaryFile(GLSetting.tmp_upload_path)
     a.avoid_delete()
     antani = "0123456789" * 10000
     a.write(antani)
     a.close()
     self.assertTrue(os.path.exists(a.filepath))
     os.remove(a.keypath)
     self.assertRaises(IOError, GLSecureFile, a.filepath)
开发者ID:Acidburn0zzz,项目名称:GLBackend,代码行数:11,代码来源:test_security.py

示例4: test_003_temporary_file_avoid_delete

# 需要导入模块: from globaleaks.security import GLSecureTemporaryFile [as 别名]
# 或者: from globaleaks.security.GLSecureTemporaryFile import avoid_delete [as 别名]
 def test_003_temporary_file_avoid_delete(self):
     a = GLSecureTemporaryFile(GLSetting.tmp_upload_path)
     a.avoid_delete()
     antani = "0123456789" * 10000
     a.write(antani)
     a.close()
     self.assertTrue(os.path.exists(a.filepath))
     b = GLSecureFile(a.filepath)
     self.assertTrue(antani == b.read())
开发者ID:Acidburn0zzz,项目名称:GLBackend,代码行数:11,代码来源:test_security.py

示例5: get_dummy_file

# 需要导入模块: from globaleaks.security import GLSecureTemporaryFile [as 别名]
# 或者: from globaleaks.security.GLSecureTemporaryFile import avoid_delete [as 别名]
def get_dummy_file(filename=None, content_type=None, content=None):
    filename = ''.join(unichr(x) for x in range(0x400, 0x40A))

    content_type = 'application/octet'

    content = ''.join(unichr(x) for x in range(0x400, 0x40A))

    temporary_file = GLSecureTemporaryFile(GLSettings.tmp_upload_path)

    temporary_file.write(content)
    temporary_file.avoid_delete()

    return {
        'body': temporary_file,
        'body_len': len(content),
        'body_filepath': temporary_file.filepath,
        'filename': filename,
        'content_type': content_type,
        'submission': False
    }
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:22,代码来源:helpers.py

示例6: test_post

# 需要导入模块: from globaleaks.security import GLSecureTemporaryFile [as 别名]
# 或者: from globaleaks.security.GLSecureTemporaryFile import avoid_delete [as 别名]
    def test_post(self):

        temporary_file = GLSecureTemporaryFile(GLSetting.tmp_upload_path)
        temporary_file.write("ANTANI")
        temporary_file.avoid_delete()

        request_body = {
            'body': temporary_file,
            'body_len': len("ANTANI"),
            'body_filepath': temporary_file.filepath,
            'filename': 'en.json',
            'content_type': 'application/json'
        }

        handler = self.request({}, role='admin', kwargs={'path': GLSetting.static_path}, body=request_body)

        yield handler.post(lang='en')

        self.assertTrue(isinstance(self.responses, list))
        self.assertEqual(len(self.responses), 1)
        self._handler.validate_message(json.dumps(self.responses[0]), requests.staticFile)
开发者ID:Acidburn0zzz,项目名称:GLBackend,代码行数:23,代码来源:test_admlangfiles.py


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