zipfile

zipfile module giving unreliable results

雨燕双飞 提交于 2019-12-08 02:13:30
问题 I made a dictionary attack on encrypted zip files, using the zipfile library. When I started using BIG dictionaries sometimes I got false positive results, i.e. password could be "wool" and "12630" was considered correct. In that case the decrypted file contained gibberish obviously. It's not a bug in my code, but in the way the zipfile library checks to see if the provided password is correct. I've managed to decrease the false positives by checking the size of the decrypted file and if it's

log4j.RollingFileAppender not compressing files

六月ゝ 毕业季﹏ 提交于 2019-12-08 01:01:36
问题 How to zip backup file in log4j RollingFileAppender I have following log4j.properties file , while exceeding size limit it is creating backup file but not zipping it. log4j.appender.request=org.apache.log4j.RollingFileAppender log4j.appender.request.File=${catalina.home}/webapps/Sample/WEB-INF/logs/FAW_l4j.log log4j.appender.request.MaxFileSize=10KB log4j.appender.request.MaxBackupIndex=3 log4j.appender.request.RollingPolicy.ActiveFileName =${catalina.home}/webapps/Sample/WEB-INF/logs/FAW_l4j

Download and unzip file with Python

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 16:02:23
问题 I am trying to download and open a zipped file and seem to be having trouble using a file type handle with zipfile. I'm getting the error "AttributeError: addinfourl instance has no attribute 'seek'" when running this: import zipfile import urllib2 def download(url,directory,name): webfile = urllib2.urlopen('http://www.sec.gov'+url) webfile2 = zipfile.ZipFile(webfile) content = zipfile.ZipFile.open(webfile2).read() localfile = open(directory+name, 'w') localfile.write(content) localfile.close

Saving zip list to csv in Python

时光怂恿深爱的人放手 提交于 2019-12-07 09:59:21
问题 How I can write below zip list to csv file in python? [{'date': '2015/01/01 00:00', 'v': 96.5}, {'date': '2015/01/01 00:01', 'v': 97.0}, {'date': '2015/01/01 00:02', 'v': 93.75}, {'date': '2015/01/01 00:03', 'v': 96.0}, {'date': '2015/01/01 00:04', 'v': 94.5} I have this error: _csv.Error: sequence expected My code is here: import csv res = zip_list csvfile = "/home/stm/PycharmProjects/isbak_trafik/example.csv" with open(csvfile, "w") as output: writer = csv.writer(output, lineterminator='\n'

How to download multiple files from S3 as Zip format in Rails 5.x.x app?

北城以北 提交于 2019-12-07 07:25:28
问题 I am implementing feature which allows user to either download single file or multiple files from S3. Single file downloading is working properly, but for multiple files I am receiving error on Heroku, Errno::ENOENT (No such file or directory @ rb_file_s_lstat ) Controller code snippet for downloading files as zip format is as below, def method_name zipfile_name = "#{Rails.root}/public/archive.zip" Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile | @transfer.transfer_attachments

Strange “BadZipfile: Bad CRC-32” problem

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 06:14:06
问题 This code is simplification of code in a Django app that receives an uploaded zip file via HTTP multi-part POST and does read-only processing of the data inside: #!/usr/bin/env python import csv, sys, StringIO, traceback, zipfile try: import io except ImportError: sys.stderr.write('Could not import the `io` module.\n') def get_zip_file(filename, method): if method == 'direct': return zipfile.ZipFile(filename) elif method == 'StringIO': data = file(filename).read() return zipfile.ZipFile

load a pickle file from a zipfile

瘦欲@ 提交于 2019-12-07 03:32:05
问题 For some reason I cannot get cPickle.load to work on the file-type object returned by ZipFile.open(). If I call read() on the file-type object returned by ZipFile.open() I can use cPickle.loads though. Example .... import zipfile import cPickle # the data we want to store some_data = {1: 'one', 2: 'two', 3: 'three'} # # create a zipped pickle file # zf = zipfile.ZipFile('zipped_pickle.zip', 'w', zipfile.ZIP_DEFLATED) zf.writestr('data.pkl', cPickle.dumps(some_data)) zf.close() # # cPickle

Create zip file from all files in folder

北城余情 提交于 2019-12-07 02:15:22
问题 I'm trying to create a zip file from all files in a folder, but can't find any related snippet online. I'm trying to do something like this: DirectoryInfo dir = new DirectoryInfo("somedir path"); ZipFile zip = new ZipFile(); zip.AddFiles(dir.getfiles()); zip.SaveTo("some other path"); Any help is very much appreciated. edit: I only want to zip the files from a folder, not it's subfolders. 回答1: Referencing System.IO.Compression and System.IO.Compression.FileSystem in your Project using System

'IBM437' is not a supported encoding name from ZipFile Read Method

荒凉一梦 提交于 2019-12-06 22:29:41
问题 I have a problem when my code execute this using: using (ZipFile archive = ZipFile.Read(File)) //<== Crash Here! { foreach (ZipEntry entry in archive.Entries) { entry.Extract(UnZipFolder.Name.ToString(), ExtractExistingFileAction.OverwriteSilently); } } Crash when ZipFile try to read my File that it's a string and contains, sincrofit.zip then crash and throw this exception: 'System.ArgumentException' Additional information: 'IBM437' is not a supported encoding name. 回答1: In Visual Studio:

log4j.RollingFileAppender not compressing files

落爺英雄遲暮 提交于 2019-12-06 10:51:05
How to zip backup file in log4j RollingFileAppender I have following log4j.properties file , while exceeding size limit it is creating backup file but not zipping it. log4j.appender.request=org.apache.log4j.RollingFileAppender log4j.appender.request.File=${catalina.home}/webapps/Sample/WEB-INF/logs/FAW_l4j.log log4j.appender.request.MaxFileSize=10KB log4j.appender.request.MaxBackupIndex=3 log4j.appender.request.RollingPolicy.ActiveFileName =${catalina.home}/webapps/Sample/WEB-INF/logs/FAW_l4j.log-%d.log. log4j.appender.request.RollingPolicy.FileNamePattern=${catalina.home}/webapps/Sample/WEB