Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > Peter Otten <__pete...@web.de> wrote: > > - consider shutil.copyfileobj to limit memory usage when dealing with data > > of arbitrary size. > > > > Putting it together:

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > > I have a problem with it: There is no feedback for the user about the > > progress of the transfer, which can last several hours. > > > > For small files shutil.copyfileobj() is a good idea, but not for huge > > ones. > > Indeed. Have a look at the

Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Marko Rauhamaa <ma...@pacujo.net> wrote: > Ulli Horlacher <frams...@rus.uni-stuttgart.de>: > > > What is the best practise for a cross platform timeout handler? > > Here's the simplest answer: > >https://docs.python.org/3/library/threading.html#threading.

cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
I am rewriting a Perl program into Python (2.7). It must run on Linux and Windows. With Linux I have no problems, but Windows... :-( The current show stopper is signal.SIGALRM which is not available on Windows: File "fexit.py", line 674, in formdata_post

Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Marko Rauhamaa wrote: > I'm thinking the only portable way is to run a watchdog process with > subprocess or multiprocessing. How can a subprocess interrupt a function in another process? For example: waiting for user input with a timeout. raw_input("Hit ENTER to continue or

Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Terry Reedy <tjre...@udel.edu> wrote: > On 11/11/2015 11:16 AM, Ulli Horlacher wrote: > > I am rewriting a Perl program into Python (2.7). > > I recommend using 3.4+ if you possibly can. It is not possible. The main target platform offers only python 2.7

Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Marko Rauhamaa wrote: > Correct. The timer callback function (hello) would be called in a > separate thread. An exception raised in one thread cannot be caught in > the main thread. In general, there is no way for a thread to interrupt a > sibling thread that is in a blocking

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > > It works with Linux, but not with Windows 7, where the downloaded 7za.exe > > is corrupt: it has the wrong size, 589044 instead of 587776 Bytes. > > > > Where is my error? > > > sz = path.join(fexhome,'7za.exe') > > szurl =

corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
I am currently developing a program which should run on Linux and Windows. Later it shall be compiled with PyInstaller. Therefore I am using Python 2.7 My program must download http://fex.belwue.de/download/7za.exe I am using this code: sz = path.join(fexhome,'7za.exe') szurl =

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > Ulli Horlacher wrote: > > > if u.getcode() == 200: > > print(u.read(),file=szo,end='') > > szo.close() > > else: > > die('cannot get %s - server reply: %d' % (szurl,u.getcode())) >

beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
I want to start a project with python. The program must have a (simple) GUI and must run on Linux and Windows. The last one as standalone executable, created with pyinstaller. I have already an implementation in perl/tk : http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png

Re: beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
Chris Angelico ros...@gmail.com wrote: On Sat, Jul 11, 2015 at 7:28 PM, Ulli Horlacher frams...@rus.uni-stuttgart.de wrote: I want to start a project with python. The program must have a (simple) GUI and must run on Linux and Windows. The last one as standalone executable, created

Re: beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
Laura Creighton l...@openend.se wrote: The question is, why do you want to reimplement this thing in Python? The Windows support of perl/pp (a perl compiler similar to pyinstall) is really bad. It does not work any more with Windows 7, I still have to use Windows XP. If the plan is to get

Re: beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
Christian Gollwitzer aurio...@gmx.de wrote: I have already an implementation in perl/tk : http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png http://fex.belwue.de/download/schwuppdiwupp.pl May I ask what is the reason to port this over to Python? Is it to learn Python, or do

Re: beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
Chris Angelico ros...@gmail.com wrote: pyinstaller can make a standalone executable, there is no need for the users to install another library. They just click on the program icon, that's it. Yeah, I'd distribute the .py files and have done with it. This is not an option for me. My

Re: beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
Paul Rubin no.email@nospam.invalid wrote: Ulli Horlacher frams...@rus.uni-stuttgart.de writes: Long ago I was involved with a thing like this and used Inno Setup, which was great. It's a very slick installer It is not a matter of knowledge, but one of user rights. It is also forbidden

Re: beginners choice: wx or tk?

2015-07-11 Thread Ulli Horlacher
Paul Rubin no.email@nospam.invalid wrote: Ulli Horlacher frams...@rus.uni-stuttgart.de writes: This is not an option for me. My users only accept standalone executables. They cannot install any runtime environment or extra libraries. Long ago I was involved with a thing like this and used

Re: beginners choice: wx or tk?

2015-07-12 Thread Ulli Horlacher
wxjmfa...@gmail.com wrote: On Windows, there are no more usable, working GUI toolkits (wrappers). What is the problem with tkinter? A first hello world program worked. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail:

handling of non-ASCII filenames?

2015-11-18 Thread Ulli Horlacher
I have written a program (Python 2.7) which reads a filename via tkFileDialog.askopenfilename() (was a good hint here, other thread). This filename may contain non-ASCII characters (German Umlauts). In this case my program crashes with: File "S:\python\fexit.py", line 1177, in url_encode

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > from Tkinter import Tk > from tkFileDialog import askopenfilename > > Tk().withdraw() > file = askopenfilename() I found another glitch: After termination of askopenfilena

Re: handling of non-ASCII filenames?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > > As I am Python newbie I have not quite understood the Python character > > encoding scheme :-} > > > > Where can I find a good introduction of this topic? > > Here are a couple of articles on the basics of Unicode: > >

Re: fexit: file transfer of ANY size

2015-11-27 Thread Ulli Horlacher
paul.hermeneu...@gmail.com wrote: > > I am now looking for beta testers. If you are interested, send me a mail. > > Can you tell us a git or svn repository from which the kit is available? Available via email request. > Or, is this a proprietary product? No. -- Ullrich Horlacher

Re: urllib2.urlopen() crashes on Windows 2008 Server

2015-12-04 Thread Ulli Horlacher
Dennis Lee Bieber wrote: > >I have a Python2 program which runs fine on Windows 7, but > >crashes on Windows 2008 Server R2 64 bit: > > > >downloading http://fex.belwue.de/download/7za.exe > >Traceback (most recent call last): > > File "", line 1992, in > > File "",

Re: urllib2.urlopen() crashes on Windows 2008 Server

2015-12-06 Thread Ulli Horlacher
Dennis Lee Bieber wrote: > >> Connection reset by peer. > >> > >> An existing connection was forcibly closed by the remote host. > > > >This is not true. > >The server is under my control. Die client has terminated the connection > >(or a router between). >

urllib2.urlopen() crashes on Windows 2008 Server

2015-12-03 Thread Ulli Horlacher
I have a Python2 program which runs fine on Windows 7, but crashes on Windows 2008 Server R2 64 bit: downloading http://fex.belwue.de/download/7za.exe Traceback (most recent call last): File "", line 1992, in File "", line 180, in main File "", line 329, in get_ID File "", line 1627, in

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > > But... is there a windows program with which one can select files and the > > result is written to STDOUT? > > Found it: > > from Tkinter import Tk > from tkFileDialog import askopenfi

Re: cannot open file with non-ASCII filename

2015-12-15 Thread Ulli Horlacher
eryk sun wrote: > pyreadline looked promising for its extensive ctypes implementation of > the Windows console API [1], wrapped by high-level methods such as > peek, getchar, and getkeypress. It turns out it ignores the event > sequences you need for alt+numpad input (used

Re: subprocess.call with non-ASCII arguments?

2015-12-15 Thread Ulli Horlacher
Dennis Lee Bieber wrote: > Python has a zipfile library that is portable between OS. Along with > libraries for gzip, bzip2, and tarfiles... Ohh.. this is new to me! https://docs.python.org/2/library/tarfile.html https://docs.python.org/2/library/zipfile.html

Re: Tk alternative to askopenfilename and askdirectory?

2015-12-16 Thread Ulli Horlacher
Lorenzo Sutton <lorenzofsut...@gmail.com> wrote: > On 16/12/2015 14:18, Ulli Horlacher wrote: > > Is there an alternative to Tk's askopenfilename() and askdirectory()? > > > > I want to select a files and directories within one widget, but > > askopenfi

pyinstaller ignores icon

2015-12-14 Thread Ulli Horlacher
pyinstaller ignores a specified icon file: the resulting executable shows the default icon on the desktop. I compile with: S:\python>pyinstaller.exe --onefile --icon=fex.ico fexit.py 31 INFO: PyInstaller: 3.0 31 INFO: Python: 2.7.11 31 INFO: Platform: Windows-7-6.1.7601-SP1 31 INFO: wrote

Re: cannot open file with non-ASCII filename

2015-12-15 Thread Ulli Horlacher
Laura Creighton wrote: > PyPy wrote its own pyreadline. > You can get it here. https://bitbucket.org/pypy/pyrepl As far as I can see, it has no getkey function. My users do not hit ENTER after drag or copy files. I need an input function with a timeout. -- Ullrich Horlacher

cannot open file with non-ASCII filename

2015-12-14 Thread Ulli Horlacher
With Python 2.7.11 on Windows 7 my users cannot open/read files with non-ASCII filenames. They use the Windows explorer to drag files into a console window running the Python program. os.path.exists() does not detect such a file and an open() fails, too. My code: print("\nDrag files or

Re: Tk alternative to askopenfilename and askdirectory?

2015-12-17 Thread Ulli Horlacher
Rick Johnson wrote: > Oh i understand. What you opine for is something like: askOpenFileOrDir() > -- which displays a dialog from which a file or directory can be selected > by the user. Yes, exactly! Now: how? -- Ullrich Horlacher Server und

Re: How does one distribute Tkinter or Qt GUI apps Developed in Python

2015-12-17 Thread Ulli Horlacher
Rick Johnson wrote: > Unlike a true "applications language", like say, um, *JAVA*, one cannot > simply compile an executable and distribute it in a teeny tiny binary > form, no, with Python Of course you can! If have done this with pyinstaller. This creates a

Re: Tk alternative to askopenfilename and askdirectory?

2015-12-18 Thread Ulli Horlacher
Christian Gollwitzer wrote: > Tk calls out into the native file manager to perform the file/open > operation (on Win, on Unix it brings it's own). This means, on Windows the user gets a "well known" file/directory browser? Then this is an important feature! Anything new and

subprocess.call with non-ASCII arguments?

2015-12-15 Thread Ulli Horlacher
I want to create a zip file within a Python 2.7 program on windows. My code: cmd = ['7za.exe','a','-tzip',archive] + files status = subprocess.call(cmd) leads to: File "fexit.py", line 971, in sendfile_retry status = subprocess.call(cmd) File "C:\Python27\lib\subprocess.py", line

Re: subprocess.call with non-ASCII arguments?

2015-12-16 Thread Ulli Horlacher
Dennis Lee Bieber wrote: > >I want to create a zip file within a Python 2.7 program on windows. > > > >My code: > > > > cmd = ['7za.exe','a','-tzip',archive] + files > > status = subprocess.call(cmd) > > > My first thought would be... > > WHY spawn an OS

Tk alternative to askopenfilename and askdirectory?

2015-12-16 Thread Ulli Horlacher
Is there an alternative to Tk's askopenfilename() and askdirectory()? I want to select a files and directories within one widget, but askopenfilename() let me only select files and askdirectory() let me only select directories. -- Ullrich Horlacher Server und Virtualisierung

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
Christian Gollwitzer wrote: > > My users do not like it :-( > > They want to drag files. > > Therefore I have added it as another option to enter files: > > > > [f] select a file > > [d] select a directory > > [e] enter a file or directory (with drag or copy) >

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
Christian Gollwitzer wrote: > Another cheap solution comes to mind: On windows, dropping files onto an > icon on the desktop is interpreted as "launch the program with > additional arguments", where the arguments are the file names. Ohhh... great! This helps me a lot! >

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > My idea now is: instead of raw_input() I use a get_paste() function, which > reads input character for input character and after a (say) 1 s timeout it > returns the string. Pasting a string with the mouse is rather fast,

Re: cannot open file with non-ASCII filename

2015-12-14 Thread Ulli Horlacher
Laura Creighton wrote: > Given that Ulli is in Germany, latin-1 is likely to work fine for him. For me, but not for my users. We have people from about 100 nations at our university. > And you do it like this: > > # -*- coding: latin-1 -*- > from Tkinter import * > root =

subprocess.call with non-ASCII arguments?

2015-12-15 Thread Ulli Horlacher
(My first posting seems to got lost) I want to create a zip file within a Python 2.7 program on windows. My code: cmd = ['7za.exe','a','-tzip',archive] + files status = subprocess.call(cmd) leads to: File "fexit.py", line 971, in sendfile_retry status = subprocess.call(cmd) File

Re: subprocess.call with non-ASCII arguments?

2015-12-15 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > Instead of calling a 7z subprocess with non-ASCII arguments I tried to > call it with a listfile: it starts with a "@" and contains the names of > the files to be packed into the arcive. It is a special

extract script from executable made by pyinstaller?

2016-01-07 Thread Ulli Horlacher
Is it possible to extract (and view) the Python script from the Windows executable which was made by pyinstller? -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de Universitaet Stuttgart Tel:

Re: extract script from executable made by pyinstaller?

2016-01-08 Thread Ulli Horlacher
Oscar Benjamin <oscar.j.benja...@gmail.com> wrote: > On 8 January 2016 at 07:44, Ulli Horlacher > <frams...@rus.uni-stuttgart.de> wrote: > > Is it possible to extract (and view) the Python script from the Windows > > executable which was made by pyinstller? >

askopenfilename() (was: Re: non-blocking getkey?)

2015-11-28 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > eryksun <eryk...@gmail.com> wrote: > > On Thu, Nov 19, 2015 at 10:31 AM, Michael Torrie <torr...@gmail.com> wrote: > > > One windows it might be possible to use the win32 api to enumerate the > > >

Re: askopenfilename()

2015-11-28 Thread Ulli Horlacher
Christian Gollwitzer <aurio...@gmx.de> wrote: > Am 28.11.15 um 11:29 schrieb Ulli Horlacher: > > One of my Windows test users reports, that the file dialog window of > > askopenfilename() starts behind the console window and has no focus. > > On Linux (XFCE) I do not h

Re: askopenfilename()

2015-11-28 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > One of my Windows test users reports, that the file dialog window of > askopenfilename() starts behind the console window and has no focus. I have got a followup: this happens only with Windows XP, not with Windows 7.

Re: askopenfilename()

2015-11-28 Thread Ulli Horlacher
Christian Gollwitzer <aurio...@gmx.de> wrote: > Am 28.11.15 um 13:48 schrieb Ulli Horlacher: > > Christian Gollwitzer <aurio...@gmx.de> wrote: > >> Many problems would simply go away if you wrote the whole thing as a GUI > >> program. > > > >

readline and TAB-completion?

2015-11-24 Thread Ulli Horlacher
I need an input function with GNU readline support. So far I have: import readline readline.parse_and_bind("tab: complete") file = raw_input('File to send: ') Cursor keys are working, but TAB-completion works only in the current directory. Example: File to send: [TAB][TAB]

Re: readline and TAB-completion?

2015-11-25 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > > Is there a way to make TAB-completion work for other directories, too? > > Remove "/" from the set of delimiters: > > readline.set_completer_delims( > "".join(c for c in readline.get_completer_delims() if c != "/")) Great! > > murksigkeiten > >

static variables

2015-11-30 Thread Ulli Horlacher
I try to to implement a "static variable" inside a function: def main(): a(1) a(2) a() print(a.x) if 'a.x' in globals(): print('global variable') if 'a.x' in locals(): print('local variable') def a(x=None): if not x is None: a.x = x print(':',a.x) main() When I run this code,

Re: static variables

2015-12-01 Thread Ulli Horlacher
Steven D'Aprano wrote: > A better and more general test is: > > if hasattr(a, 'x'): print('attribute of a') Fine! I have now: def a(x=None): if not hasattr(a,'x'): a.x = 0 a.x += 1 print('%d:' % a.x,x) This simply counts the calls of a() But, when I rename the

Re: static variables

2015-12-01 Thread Ulli Horlacher
Wolfgang Maier wrote: > I'm wondering whether you have a good reason to stick with a function. Easy handling, no programming overhead. Clean, orthogonal code. > What you are trying to achieve seems to be easier and cleaner to > implement as a class:

fexit: file transfer of ANY size

2015-11-26 Thread Ulli Horlacher
In the last weeks I have asked here some beginners questions and got great response. I was able to solve all my problems. Now, my first real Python program is ready: fexit, a F*EX client. And what is F*EX? ==> Frams' Fast File EXchange, a service for transfering files of ANY size from any user A

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > it is too complicated to rewrite my application from CLI to GUI. > But... is there a windows program with which one can select files and the > result is written to STDOUT? Found it: from Tkinter import Tk fr

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Terry Reedy wrote: > > from Tkinter import Tk > > from tkFileDialog import askopenfilename > > > > Tk().withdraw() > > file = askopenfilename() > > To get multiple names, add 's'. I have found it already, thanks. > The limitation is that this will

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Christian Gollwitzer wrote: > > How can I implement such a get_paste() function? > > I need a non-blocking getkey() function. > > It must work on Windows and Linux. > > Non-blocking I/O from the commandline is OS specific. There are > different solutions, and it's usually

non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
In my program (for python 2.7) the user must enter file names with mouse copy+paste. I use: while True: file = raw_input(prompt) if file == '': break files.append(file) The problem now is: my users do not hit ENTER after pasting. The file names are pasted together in one single line

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Steven D'Aprano wrote: > >> The limitation is that this will not work if any of the file names > >> contain astral (non-BMP) chars because tk cannot handle such characters. > > > > What are "astral chars"? > > Unicode characters beyond U+. I see, for very exotic

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > > In my application the user MUST select files and directories (in one go). > > It's extremely uncommon to be able to select a combination of files > and directories. I have an uncommon application :-) Filetransfer of ANY size:

pyinstaller and Python 3.5 on Windows?

2015-11-18 Thread Ulli Horlacher
To run my Python programs on other Windows systems without a Python installation I must create standalone Windows executables. pyinstaller runs without any problems with Python 2.7.10 on Windows 7, but with Python 3.5 I get: S:\python>pyinstaller.exe --onefile tk.py Traceback (most recent call

Re: handling of non-ASCII filenames?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > >> If you can use Python 3 > > > > I cannot use it, because the Python compiler pyinstaller does not work > > with it on Windows: > > > > S:\python>pyinstaller.exe --onefile tk.py > > Traceback (most recent call last): > > File

Re: handling of non-ASCII filenames?

2015-11-19 Thread Ulli Horlacher
Christian Gollwitzer <aurio...@gmx.de> wrote: > Am 18.11.15 um 17:45 schrieb Ulli Horlacher: > > This is my encoding function: > > > > def url_encode(s): > >u = '' > >for c in list(s): > > if match(r'[_=:,;<>()+.\w\-]

Re: pyinstaller and Python 3.5 on Windows?

2015-11-18 Thread Ulli Horlacher
Christian Gollwitzer <aurio...@gmx.de> wrote: > Am 18.11.15 um 23:46 schrieb Ulli Horlacher: > > To run my Python programs on other Windows systems without a Python > > installation I must create standalone Windows executables. > > > > pyinstaller runs withou

Re: pyinstaller and Python 3.5 on Windows?

2015-11-19 Thread Ulli Horlacher
Kevin Walzer wrote: > I understand that Python 3.5 has shipped how the MS dll's from Visual > Studio are shipped, and perhaps the freezing tools (pyinstaller, py2exe) > haven't yet caught up. Consider filing a bug with the pyinstaller > developers.

Re: non-blocking getkey?

2015-11-23 Thread Ulli Horlacher
eryksun wrote: > On Thu, Nov 19, 2015 at 10:31 AM, Michael Torrie wrote: > > One windows it might be possible to use the win32 api to enumerate the > > windows, find your console window and switch to it. > > You can call GetConsoleWindow [1] and then

Re: non-blocking getkey?

2015-11-19 Thread Ulli Horlacher
Terry Reedy <tjre...@udel.edu> wrote: > On 11/18/2015 11:50 AM, Ulli Horlacher wrote: > > Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > > > >> from Tkinter import Tk > >> from tkFileDialog import askopenfilename > >

Re: pyinstaller and Python 3.5 on Windows?

2015-11-19 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > C:\Users\admin>pip install pypiwin32 > Collecting pypiwin32 > Downloading pypiwin32-219-cp35-none-win32.whl (7.9MB) > 100% || 7.9MB 61kB/s > Installing collected package

looking for windows testers

2016-01-11 Thread Ulli Horlacher
I have written a Python client for F*EX(*). It is designed for Windows users, though it runs on UNIX, too. I am now looking for testers. If you are interested, I will give you an account on my server. (*) Frams' Fast File EXchange is a service to send files of any size to any user anywhere

Re: When I need classes?

2016-01-10 Thread Ulli Horlacher
Cameron Simpson wrote: > I always structure this aspect as: > > ... at or near top of script ... > > def main(argv): >... do main logic here ... > > ... at bottom ... > if __name__ == '__main__': >sys.exit(main(sys.argv)) I, as a Python beginner, came to the same

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Ulli Horlacher
Charles T. Smith wrote: > while ($str != $tail) { > $str ~= s/^(head-pattern)//; > use ($1); > } use() is illegal syntax in Perl. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail:

getkey

2016-01-16 Thread Ulli Horlacher
I have an application which runs on Windows and UNIX where I need to get one keypress from the user (without ENTER). Keys which sends escape sequences (e.g. cursor or function keys) should be ignored. I have a solution for Windows, but not for UNIX: The first byte of an escape sequence

"x == None" vs "x is None"

2016-01-17 Thread Ulli Horlacher
I have seen at several places "x == None" and "x is None" within if-statements. What is the difference? Which term should I prefer and why? -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de Universitaet Stuttgart

Re: getkey

2016-01-16 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > The first byte of an escape sequence (example: ^[[21~ for F10) is > recognized, but the trailing bytes then are not discarded by > clear_keyboard_buffer() and get_key() returns the second byte of the > escape seque

Re: "x == None" vs "x is None"

2016-01-17 Thread Ulli Horlacher
Chris Angelico <ros...@gmail.com> wrote: > On Sun, Jan 17, 2016 at 8:51 PM, Ulli Horlacher > <frams...@rus.uni-stuttgart.de> wrote: > > I have seen at several places "x == None" and "x is None" within > > if-statements. > > What is the differ

Re: OT The fiction section

2016-01-17 Thread Ulli Horlacher
Marko Rauhamaa wrote: > Steven D'Aprano : > > > https://pbs.twimg.com/media/CWgV0ruUsAAcUD7.jpg > > Not bad. $ python Python 2.7.3 (default, Jun 22 2015, 19:33:41) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license"

tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
https://docs.python.org/2/library/tarfile.html says: tarfile.open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs) Return a TarFile object for the pathname name. (How) can I read a tar file from a (tcp) socket? I do not have a pathname but a socket object from

Re: tarfile : read from a socket?

2016-02-12 Thread Ulli Horlacher
Lars Gustäbel wrote: > On Fri, Feb 12, 2016 at 09:35:40AM +0100, Antoon Pardon wrote: > > On 02/11/2016 06:27 PM, Lars Gustäbel wrote: > > > What about using an iterator? > > > > > > def myiter(tar): > > > for t in tar: > > > print "extracting", t.name > > >

Re: tarfile : secure extract?

2016-02-12 Thread Ulli Horlacher
Random832 <random...@fastmail.com> wrote: > On Thu, Feb 11, 2016, at 18:24, Ulli Horlacher wrote: > > A better approach would be to rename such files while extracting. > > Is this possible? > > What happens if you change member.name before extracting? O

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Antoon Pardon wrote: > > (How) can I read a tar file from a (tcp) socket? > > I do not have a pathname but a socket object from socket.create_connection > > # First you construct a file object with makefile. > > fo = socket.makefile() > > # Then you use the

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Chris Angelico wrote: > Sounds like tarfile needs a seekable file. How big is this file you're > reading? No limits. It can be many TBs... The use case is: http://fex.rus.uni-stuttgart.de:8080/ -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > I have: > > sock = socket.create_connection((server,port)) > bs = kB64 > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w') > > > > Traceback (most recent call last): >

tarfile : secure extract?

2016-02-11 Thread Ulli Horlacher
In https://docs.python.org/2/library/tarfile.html there is a warning: Never extract archives from untrusted sources without prior inspection. It is possible that files are created outside of path, e.g. members that have absolute filenames starting with "/" or filenames with two dots "..".

Re: psss...I want to move from Perl to Python

2016-01-29 Thread Ulli Horlacher
James Harris wrote: > I nearly gave up with Python at the very beginning before I realised not > to mix tabs and spaces. I nearly gave up with Python at the very beginning before I realised that OO-programming is optional in Python! :-) Most tutorials I found so far

Re: psss...I want to move from Perl to Python

2016-01-29 Thread Ulli Horlacher
Steven D'Aprano wrote: > Every time I make a half-hearted attempt to learn enough Perl syntax to get > started, I keep running into the differences between $foo, %foo and @foo > and dire warnings about what happens if you use the wrong sigil I have started learning Python

extending PATH on Windows?

2016-02-16 Thread Ulli Horlacher
I need to extend the PATH environment variable on Windows. So far, I use: system('setx PATH "%PATH%;'+bindir+'"') The problem: In a new process (cmd.exe) PATH contains a lot of double elements. As far as I have understood, Windows builds the PATH environment variable from a system component

Re: extending PATH on Windows?

2016-02-16 Thread Ulli Horlacher
Thorsten Kampe <thors...@thorstenkampe.de> wrote: > * Ulli Horlacher (Tue, 16 Feb 2016 08:30:59 + (UTC)) > > I need to extend the PATH environment variable on Windows. > > 1. Add the path component yourself into HKEY_CURRENT_USER and make > sure it's not th

Re: extending PATH on Windows?

2016-02-17 Thread Ulli Horlacher
Thorsten Kampe wrote: > By the way: there is a script called `win_add2path.py` in your Python > distribution I have "Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32" and there is no "win_add2path.py" But I found

Re: extending PATH on Windows?

2016-02-17 Thread Ulli Horlacher
eryk sun wrote: > > At startup cmd.exe runs a script which is defined by the registry variable > > AutoRun in "HKCU\Software\Microsoft\Command Processor" > > > > I set this variable with: > > > > rc = "HKCU\Software\Microsoft\Command Processor" > > ar =

Re: extending PATH on Windows?

2016-02-17 Thread Ulli Horlacher
eryk sun wrote: > >> The AutoRun command (it's a command line, not a script path) > > > > A script path is a legal command line, too. > > If the registry value were just a script path, you'd have to modify > your script to chain to the previous script, if any. Since it's a >

Re: extending PATH on Windows?

2016-02-18 Thread Ulli Horlacher
Dennis Lee Bieber wrote: > >I have > >"Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC > >v.1500 32 bit (Intel)] on win32" > >and there is no "win_add2path.py" > > > C:\Python_x64\Python27\Tools\scripts\win_add2path.py Ok, It is here in

Re: extending PATH on Windows?

2016-02-18 Thread Ulli Horlacher
eryk sun wrote: > https://hg.python.org/cpython/file/v2.7.11/Tools/scripts/win_add2path.py > > But there are a few issues with this script. (... lot of flaws ...) > Here's a new version for Python 2. I generalized the shell-variable > replacement to a list of well-known

Re: extending PATH on Windows?

2016-02-18 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > > but simpler still and more reliable to just call QueryValueEx. > > I find it more complicated. I have now (after long studying docs and examples):: def get_winreg(key,subkey): try: rkey = winreg.OpenKey(winreg

Re: extending PATH on Windows?

2016-02-19 Thread Ulli Horlacher
pyotr filipivich wrote: > > Windows (especially 7) search function is highly crippled. There is > >some command sequence that will open it up to looking at other file types > >and locations. > > >

Re: modifying a standard module?

2016-02-12 Thread Ulli Horlacher
Matt Wheeler wrote: > > How can I substitute the standard module function tarfile.extractall() with > > my own function? > > import tarfile > def new_extractall(self, *args, **kwargs): > print("I am a function. Woohoo!") > > tarfile.TarFile.extractall = new_extractall

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > With > > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') > > I get no more error. Of course, this is the writing client. Now I have a small problem with the reading client. This code

modifying a standard module? (was: Re: tarfile : read from a socket?)

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > This code works so far: > > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) > > But it does not writes anything to the terminal to infor

manually sorting images?

2016-09-04 Thread Ulli Horlacher
I need to sort images (*.jpg), visually, not by file name. It looks, there is no standard UNIX tool for this job? So, I have to write one by myself, using Tkinter. Are there any high-level widgets which can help me, for example a file browser with thumbnails? -- Ullrich Horlacher

  1   2   >