python unzip
At first, I tried to use 'os.popen3("unz ip ...") like this:
fin, fout, ferr = os.popen3("unzi p -o -d %s %s" % (dest, zipfile))
strerr = ferr.read()
# This makes the program hanging up
if strerr:
print >sys.stderr, strerr
outlog.error(st rerr)
I want to know is this caused by the 'unzip' command does not print
'EOF'? or any other reasons?
At last I did this to do 'unzip':
import zipfile
def _extract_all(se lf, destdir):
namelist = self.namelist()
namelist.sort()
for name in namelist:
if name.endswith('/'):
print name
os.mkdir(os.pat h.join(destdir, name))
else:
outfile = open(os.path.jo in(destdir, name), 'wb')
outfile.write(s elf.read(name))
outfile.close()
zipfile.ZipFile .extract_all = _extract_all
def unzip(...):
zipo = zipfile.ZipFile (zipfn, 'r')
zipo.extract_al l(dest)
But I still want to know the reason why can't os.popen3("unzi p ...")
be used.
Thanks. 0 1670 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sang park |
last post by:
Hi all - Just started learning Python this past week and had a question
about using the lists in python with objects. (code attached below).
basically, what i want to do is read an xml file, and load a list of Objects
(in this case, TTSProject objects). the problem i see when i try to run it,
is the following:
name :
Traceback (most recent call last):
File "ProjectParser.py", line 63, in ?
|
by: Vio |
last post by:
Hi,
I've been trying to embed (statically) wxPy alongside an embedded py
interpreter on a linux/gtk box.
At one point, for some reason misc.o linking reported "multiple
definitions of wxGetFreeMemory()". Since wxGetFreeMemory() seemed
effectively unused in gtk, I just commented it out in misc_wrap.cpp
(didn't want to patch SWIG to regenerate the wrapper code, so hacked the
generated cpp source), and replaced...
|
by: beliavsky |
last post by:
Ideally, one can use someone's C++ code by just looking at the header
files
(which should contain comments describing the functions in addition to
function definitions), without access to the full source code. Can
analogs of C++ header files be created for Python code?
Python "header" files could list only the 'def' statements and
docstrings of Python functions and classes, but that does not tell you
what the functions return. One could...
|
by: David Dürrenmatt |
last post by:
Hi.
If I try to use decompyle (decompyle-2.3) for pyc-files < version 2.0, I
get an error with marshal_20 (ImportError: dynamic module does not define
init function (initmarshal_20) ). marshal_20 was compiled to a so-file
using gcc.
Does anybody know where this error could come from and how to solve it?
Thanks,
|
by: John Nagle |
last post by:
This bug, " robotparser interactively prompts for username and
password", has been open since 2003. It killed a big batch job of ours
last night.
Module "robotparser" naively uses "urlopen" to read "robots.txt" URLs.
If the server asks for basic authentication on that file, "robotparser"
prompts for the password on standard input. Which is rarely what you
want. You can demonstrate this with:
import robotparser
| |
by: Ivan Voras |
last post by:
Hi,
I'm looking for a construct that's similar to (Turbo) Pascal's "with"
statement. I read about the Python's new "with" statement, but I was
dissapointed to learn that it does something different (I still don't
see how it's better than try..except..finally, but that's not my question).
Is there something similar to what I want that's Pythonic enough?
(If you're not familiar with Pascal, here's how it works:
|
by: ureuffyrtu955 |
last post by:
Python is a good programming language, but "Python" is not a good
name.
First, python also means snake, Monty Python. If we search "python" in
google, emule, many results are not programming resource. If we search
PHP, all results are programming resource.
Second, python also means snake, snake is not a good thing in western
culture. Many people dislike any things relevant to snake. We must
have high regard for the custom.
|
by: bsagert |
last post by:
After a couple of weeks studying Python, I already have a few useful
scripts, including one that downloads 1500 Yahoo stock quotes in 6
seconds. However, many things are puzzling to me. I keep on seeing
things like "__main__" in scripts. A more obscure example would be
"__add__" used in string concatenation. For example, I can use "Hello
"+"world (or just "Hello" "world") to join those two words. But I can
also use "Hello...
|
by: chardish |
last post by:
Hello,
I'm trying to find out in a script where the location of the current
python is. (I'm writing an installer script in python for a simple
server application, so i'm going to do a find-replace in a bunch of
files to give them the absolute path of the python binary.
One thought might be to use the subprocess module, run "which python"
as a subprocess, and then peek at stdout, but that seems way too
complicated. Is there a simple...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |