[issue45628] TimedRotatingFileHandler backupCount not working

2021-10-27 Thread Ivo Grondman


New submission from Ivo Grondman :

Using the TimedRotatingFileHandler with a non-zero backupCount, I get different 
behaviour between versions 3.9 and 3.10.

Attached is a small example. Running it with 3.9 gives me two backups at most 
even if I run the script for a long time. Running it with 3.10 does not delete 
old backup files at all and just keeps writing new ones.

--
components: Library (Lib), macOS
files: logrotate.py
messages: 405104
nosy: ivogrondman, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: TimedRotatingFileHandler backupCount not working
versions: Python 3.10
Added file: https://bugs.python.org/file50397/logrotate.py

___
Python tracker 
<https://bugs.python.org/issue45628>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality inconsistency

2020-12-28 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

Yes, I get it now. I've missed the idea. You can do:

> age = tk.IntVar(value=38, name="mine")
> age_str = tk.StringVar(name="mine")
> is_alive = tk.BooleanVar(name="mine")
> is_alive.get()
True

Maybe not the best example, but still, it was a misunderstanding.

Thank you very much, Serhiy, once again!

--

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality inconsistency

2020-12-27 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

"I personally think that being able to compare whether two tkinter variables 
point to the same Tk variable is very useful so needs to stay in some form." -- 
I concur.

"However, I don't see any situation where comparing to see if two tkinter 
variables are the same Python object would be helpful." -- agreed.

"Therefore, while writing 'a.get() == b.get()' isn't too bad, .." -- it isn't. 
But "a == b" -> False IS, provided that "a.get() == b.get()" is True.

Serhiy, how about:

> class Variable:
> ...
> def is_(self, other):  # or maybe "same_as"
> return self.__class__.__name__ == other.__class__.__name__ \
> and self._name == other._name
>
> def __eq__(self, other):
> return self.__class__.__name__ == other.__class__.__name__ \
> and self.get() == other.get()

Regards

--

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality inconsistency

2020-12-27 Thread Ivo Shipkaliev


Change by Ivo Shipkaliev :


--
title: tkinter.Variable equality consistency -> tkinter.Variable equality 
inconsistency

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

2. (continued) .. This is including the case when both variables have the same 
internal name (the current implementation).

--

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

There are 2 good reasons for making Tk variables comparable by value:

   1. We honor the equality operator! The equality operator (==) has to compare 
two objects by value. The current implementation does not fulfil this. Yes, if 
two Tk variables have the same names in the Tcl interpreter, they are 
guaranteed to have the same value.

>>> a = tk.IntVar(name='a')
>>> b = tk.IntVar(name='a')
>>> assert a == b  # this is not enough; equality means "by value"
   # what about when they don't have the same name?

>>> assert a is not b  # this again does not make sense, since
   # both Python "a" and "b" identifiers lead to
   # the same "self._tk.globalgetvar(self._name)"
   # Tcl registered variable: name="a"

>>> a.set(42); assert b.get() == a.get() == 42  # yes!
# equality in names guarantees equality in value

Yes ... BUT, the negation is not true: if two Tk variables have different 
names, that does NOT mean that they have different values. This is where we 
fail the equality operator:

>>> c = tk.IntVar(name='c', value=42)
>>> assert a._name != c._name and a.get() != c.get(), \
... "Difference in names does not guarantee difference in value"

   2. When we're interested in Tk variable comparison: .get() becomes 
redundant. Every time two Tk variables are of the same type AND they refer to 
the same value, we can safely compare them as equal, regardless of how they are 
named in the Tcl interpreter.

--

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

If it's gonna break existing code -- fine. I just wanted to point out that if 
two variables are of the same type and refer to the same value, they should be 
considered equal, even if they are not the same variable.

In the current implementation, two StrVars can hold the same strings, but are 
compared unequal, which doesn't seem right.

Considering that we are going through the Tcl interpreter, equality should 
compare by value, not by identity (regardless of the variable names).

Look at this, please.

>>> int_0 = tk.IntVar()
>>> int_0.set(51)

>>> int_1 = tk.IntVar()
>>> int_1.set(51)


How can:

>>> int_0.get() == int_1.get()
True

and

>>> type(int_0) == type(int_1)
True

..but:

>>> int_0 == int_1
False

This means that the equality operator is only showing the difference in their 
names, and the statement above loses meaning, as it can never return True.

I think "int_0 is int_1" should be False as it is now. "is" should take into 
account their names as defined in the Tcl interpreter.

But "int_0 == int_1" should be True. Same as a couple of identical Python lists 
with different names.

Thank you!

--

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42750] tkinter.Variable equality consistency

2020-12-26 Thread Ivo Shipkaliev


New submission from Ivo Shipkaliev :

Greetings!

I just noticed:

>>> import tkinter as tk
>>> root = tk.Tk()

>>> str_0 = tk.StringVar()
>>> str_0.set("same value")

>>> str_1 = tk.StringVar()
>>> str_1.set("same value")

So:

>>> str_0.get() == str_1.get()
True

But:

>>> str_0 == str_1
False

So, maybe a Variable should be compared by value, and not by identity (._name) 
as currently? (please view attached) Does it make sense?

--
components: Tkinter
files: equality.diff
keywords: patch
messages: 383807
nosy: epaine, serhiy.storchaka, shippo_
priority: normal
severity: normal
status: open
title: tkinter.Variable equality consistency
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file49698/equality.diff

___
Python tracker 
<https://bugs.python.org/issue42750>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42672] tkinter/__init__.py raises a NameError if NoDefaultRoot()

2020-12-19 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

Thank you!

--

___
Python tracker 
<https://bugs.python.org/issue42672>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42672] tkinter/__init__.py raises a NameError if NoDefaultRoot()

2020-12-17 Thread Ivo Shipkaliev


Change by Ivo Shipkaliev :


--
components: Tkinter
files: default_root.diff
keywords: patch
nosy: shippo_
priority: normal
severity: normal
status: open
title: tkinter/__init__.py raises a NameError if NoDefaultRoot()
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file49690/default_root.diff

___
Python tracker 
<https://bugs.python.org/issue42672>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raises obscure AttributeError

2020-12-15 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

First: thank you!

> I think Serhiy has done a very good job ...

I'm not saying he ain't! More so, I greatly appreciate everyone's time and 
effort. But I'm discussing the implementation here, not somebody's work.

Apparently I haven't been precise enough in conveying my message. Let me try to 
clarify what I mean. Consider the following:

An object gets initialized. The object's constructor accepts a "master" 
optional parameter (e.g. Variable.__init__). So, every time:
   -- "master" is None
  and
   -- _support_default_root is True
a default root must be instantiated. A master is optional, and when it's not 
given and _support_default_root switch is on, a default root should be 
supplied. That's the whole point of _support_default_root after all.

My understanding of the module is not as deep as yours', but getboolean(), 
mainloop() and image_types() shouldn't be affected.

"Too early to create image: no default root window": Why isn't there? When 
_support_default_root is on.

Again, I can see that:

> "no default root window" is correct

:But why is there no default window? Support default root is on, right?

> There is no yet default root window required by the function.

:A default root is required when you instantiate an Image without a "master". 
It's not required as an argument, but it is required for the operation of Image.
I'm suggesting something like:

> class Variable:
> ...
> def __init__(self, master=None, value=None, name=None):
> ...
> master = master or _get_default_root()
> self._root = master._root()
> ...

> class Image:
> ...
> def __init__(self, imgtype, name=None, cnf={}, master=None, **kw):
> ...
> master = master or _get_default_root()
> self.tk = getattr(master, 'tk', master)
> ...

Best Wishes
Ivo Shipkaliev

--

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raises obscure AttributeError

2020-12-15 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

Thank you very much, fellows!

Serhiy, I'm lloking at Lib/tkinter/__init__.py changes. I'd like to share my 
thoughts on this:

I understand your concern: "But I am not sure what is better: raise error 
(RuntimeError) if the global function uses _default_root which is not 
initialized, or create the root widget implicitly."

In the new _get_default_root() function, first we check if Support Default Root 
in on:

290 > if not _support_default_root:

If we get passed this block, we know that Support Default Root is on, meaning 
that all entities that require a master, but didn't receive one passed-in, must 
receive a default one. That's how I perceive the whole idea behind Support 
Default Root.

But later on we do:

293 > if not _default_root:
294 > if what:
295 > raise RuntimeError(f"Too early to {what}: no default root 
window")

At this point, if "what" evaluates to True, we raise a RuntimeError. But at 
this same time Support Default Root is on, and there is no default root. And 
clearly: ".. no default root window" error contradicts the 
"_support_default_root" idea.

So further on, assuming Support Default Root is on, if we instantiate a 
Variable with master=None, we would get: "Too early to create variable: no 
default root window", which makes no sense.

In my view, we should always create a default root if it's needed, provided 
that _support_default_root is True. Simply: Support Default Root must lead to a 
default root.

Best Regards

--

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raises obscure AttributeError

2020-12-14 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

"Attached is a diff which ..." -- Much nicer!

Are you gonna submit a PR so I can eventually use _setup_master() in my PR?

--

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raises obscure AttributeError

2020-12-14 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

The current implementation is already relying on _some_ master anyway:

335 > self._root = master._root()

So, initializing a default root, if one isn't present, shouldn't break 
anything. And reusing setup_master() is a good idea. Maybe:

333 > master = setup_master(master)
334 > self._root = master._root()

But:

> from tkinter.ttk import setup_master

leads to a circular import error. I'll look into this.

--

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raises obscure AttributeError

2020-12-14 Thread Ivo Shipkaliev


Change by Ivo Shipkaliev :


--
resolution: works for me -> 

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ to raise a RuntimeError instead of obscure AttributeError

2020-12-13 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

Sorry, we need "global" too:

333 > if not master:
334 > global _default_root
335 > if not _default_root:
336 > _default_root = Tk()
337 > master = _default_root
338 > self._root = master._root()

--
resolution:  -> works for me

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ to raise a RuntimeError instead of obscure AttributeError

2020-12-13 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

Or maybe:

333 > if not master:
334 > if not _default_root:
335 > _default_root = Tk()
336 > master = _default_root
337 > self._root = master._root()

--
title: Variable.__init__ raise a RuntimeError instead of obscure AttributeError 
-> Variable.__init__ to raise a RuntimeError instead of obscure AttributeError

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raise a RuntimeError instead of obscure AttributeError

2020-12-13 Thread Ivo Shipkaliev


Ivo Shipkaliev  added the comment:

https://mail.python.org/archives/list/python-id...@python.org/thread/FSQUFJJQDNSRN4HI7VFXWCNO46YLXQDS/

--

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42630] Variable.__init__ raise a RuntimeError instead of obscure AttributeError

2020-12-13 Thread Ivo Shipkaliev


New submission from Ivo Shipkaliev :

Hello.

I think it would be nice to add:

335 > if not master:
336 > raise RuntimeError('a valid Tk instance is required.')

to lib/tkinter/__init__.py, and not rely on this unclear AttributeError.

Could it be assigned to me, please?

Best Regards
Ivo Shipkaliev

--
components: Tkinter
messages: 382944
nosy: shippo_
priority: normal
severity: normal
status: open
title: Variable.__init__ raise a RuntimeError instead of obscure AttributeError
type: behavior

___
Python tracker 
<https://bugs.python.org/issue42630>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



PEP 572 -- Assignment Expressions

2018-11-27 Thread Ivo Shipkaliev
   Hello.
   Maybe it's too late for a discussion, but I just couldn't resist.
   I just found out about this new ":=" operator. I need to ask:

   What is the need for this additional ":" to the "="?
   Why:
 if (match := pattern.search(data)) is not None:
   # Do something with match

   What is wrong with:
 if match = pattern.search(data) is not None:
   # Do something with match

   Assignment expression or assignment statement, it's an assignment,
right? It is very clear to everyone that it's an assignment! Can't it all
just be a "="?
   Thank you very much!


   Kind Regards
   Ivo Shipkaliev
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python.NET question?

2017-03-21 Thread Ivo Bellin Salarin
IronPython?

Le mar. 21 mars 2017 08:52, Tristan B. Kildaire  a
écrit :

> Is Python.NET a version of Python that compiles Python source code to
> Microsoft's IR for running by a MS runtime?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Python doesn't catch exceptions ?

2017-02-01 Thread Ivo Bellin Salarin
Hi all,

I have a curious problem with Python exceptions.

The following code doesn't catch HttpError:
```
from server.libs.googleapiclient.errors import HttpError
[..]
try:
OAuth.backoffExec(request)
return True
except HttpError as e:
return e.resp.status == 404
except Exception as e:
import inspect
import os
logging.error("caught exception: {}, defined in {}. we are in
{}".format(
e.__class__.__name__,
inspect.getfile(e.__class__),
os.getcwd()
))
logging.error("processed exception: {}, defined in {}.".format(
HttpError.__name__,
inspect.getfile(HttpError)
))
logging.error('e is an HttpError? {}'.format(isinstance(e,
HttpError)))
```

This code generates instead the messages:
```
ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError,
defined in server/libs/googleapiclient/errors.pyc. we are in
/Users/nilleb/dev/gae-sample-project/app
ERROR 47.135[bigquery.py.create_table:366] processed exception: HttpError,
defined in
/Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc.
ERROR 47.136[bigquery.py.create_table:368] e is an HttpError? False
```

I haven't joined the paths in the messages above, but they are identical if
I do that manually:

```
/Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc
/Users/nilleb/dev/gae-sample-project/app/server/libs/googleapiclient/errors.pyc
```

Any ideas about how to diagnostic what's going wrong?

Thanks in advance,
nilleb
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue9997] function named 'top' gets unexpected namespace/scope behaviour

2010-09-30 Thread Ivo van der Wijk

New submission from Ivo van der Wijk python@in.m3r.nl:

This issue is also discussed on Stackoverflow: 
http://stackoverflow.com/q/3828611/320057

The following code

def top(deck):
pass

def b():
global deck

results in the error SyntaxError: name 'deck' is local and global (slightly 
different for 3.x). This is strange by itself, and is caused by special 
namespace behaviour attached to the top symbol. Renaming the top function 
actually solves the error!

More technical details are in the stackoverflow link above.

--
components: Interpreter Core
messages: 117731
nosy: iivvoo
priority: normal
severity: normal
status: open
title: function named 'top' gets unexpected namespace/scope behaviour
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6112] scheduler.cancel does not raise RuntimeError

2009-05-26 Thread Ivo Danihelka

New submission from Ivo Danihelka i...@danihelka.net:

There is a misleading documentation for module sched.
Method scheduler.cancel() does not raise RuntimeError.
It raises ValueError if the given event is not in the queue.

The RuntimeError is mentioned inside the module documentation
and also inside the method __doc__ string.

--
assignee: georg.brandl
components: Documentation
messages: 88338
nosy: fidlej, georg.brandl
severity: normal
status: open
title: scheduler.cancel does not raise RuntimeError
versions: Python 2.5, Python 2.6, Python 3.0, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6112
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Python-2.3.4 on OSF1 V4.0?

2008-08-29 Thread Ivo Raisr
Hi Edmond and any interested reader,
I've successfully patched _socket extension of python 2.5.1 to build
on OSF1 V4.0 with gcc 4.1.2.
The following construct is put right after #include Python.h and
#include structmember.h:
#define _POSIX_PII_SOCKET
#define _LIBC_POLLUTION_H_

Ivosh Raisr
--
http://mail.python.org/mailman/listinfo/python-list


[issue3721] invalid literal for int() with base 16: ''

2008-08-29 Thread ivo

New submission from ivo [EMAIL PROTECTED]:

I tested metode urllib2.read() on 2000 web_pages and there was a
exception ValueError in only one case, here is short code:

import urllib2
req = urllib2.urlopen('http://www.peachbit.org/')
req.read()


Traceback (most recent call last):
  File httplib_bug.py, line 6, in module
req.read()
  File /usr/lib/python2.5/socket.py, line 291, in read
data = self._sock.recv(recv_size)
  File /usr/lib/python2.5/httplib.py, line 509, in read
return self._read_chunked(amt)
  File /usr/lib/python2.5/httplib.py, line 548, in _read_chunked
chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: ''

--
components: Installation
messages: 72121
nosy: xhomol11
severity: normal
status: open
title: invalid literal for int() with base 16: ''
type: crash
versions: Python 2.5

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3721
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: python without while and other explosive statements

2008-05-12 Thread ivo talvet
thanks for the tips, pam limits and http://codepad.org/ are both
interesting tracks.

Ivo

2008/5/12 Matt Nordhoff [EMAIL PROTECTED]:

 ivo talvet wrote:
   Hello,
  
   Is it possible to have a python which not handle the execution of
   while, for, and other loop statements ? I would like to allow
   remote execution of python on a public irc channel, so i'm looking for
   techniques which would do so people won't be able to crash my computer
   (while 1: os.fork(1)), or at least won't won't freeze my python in a
   infinite loop, make it unresponsive. Is there a compiling option (or
   better, something i can get with apt-get cos i think compiling myself
   and handle all the metastuff myself is somehow dirty) for have a
   secure python (you can guess what i mean by secure in my case) or
   must i touch myself the source disable some code lines ? If last
   solution, which modifications in which files should i do ? (sorry for
   my bad english)
  
   Thanks.
  
   Ivo

  http://codepad.org/ is a pastebin-like website that lets people upload
  code in a dozen different languages, and it runs it. They have info up
  about how it's secure at http://codepad.org/about.

  I'm pretty sure there's another similar website that's specific to
  Python, but I can't remember it. Anyway, it was similar, using virtual
  machines, a firewall, and killing stuff that ran for longer than 20
  seconds, IIRC.

  (Thanks for the link to codepad, habnabit.)
  --

--
http://mail.python.org/mailman/listinfo/python-list


python without while and other explosive statements

2008-05-11 Thread ivo talvet
Hello,

Is it possible to have a python which not handle the execution of
while, for, and other loop statements ? I would like to allow
remote execution of python on a public irc channel, so i'm looking for
techniques which would do so people won't be able to crash my computer
(while 1: os.fork(1)), or at least won't won't freeze my python in a
infinite loop, make it unresponsive. Is there a compiling option (or
better, something i can get with apt-get cos i think compiling myself
and handle all the metastuff myself is somehow dirty) for have a
secure python (you can guess what i mean by secure in my case) or
must i touch myself the source disable some code lines ? If last
solution, which modifications in which files should i do ? (sorry for
my bad english)

Thanks.

Ivo
--
http://mail.python.org/mailman/listinfo/python-list


Re: polling for output from a subprocess module

2008-02-05 Thread Ivo
Thomas Bellman wrote:
 [EMAIL PROTECTED] wrote:
 
   try:
 test = Popen(test_path,
   stdout=PIPE,
   stderr=PIPE,
   close_fds=True,
   env=test_environ)
 
 while test.poll() == None:
 ready = select.select([test.stderr], [], [])
 
 if test.stderr in ready[0]:
 t_stderr_new = test.stderr.readlines()
 if t_stderr_new != []:
 print STDERR:, \n.join(t_stderr_new)
 t_stderr.extend(t_stderr_new)
 [...]
 The problem is, that it seems that all the output from the subprocess
 seems to be coming at once. Do I need to take a different approach?
 
 The readlines() method will read until it reaches end of file (or
 an error occurs), not just what is available at the moment.  You
 can see that for your self by running:
 
 $ python -c 'import sys; print sys.stdin.readlines()'
 
 The call to sys.stdin.readlines() will not return until you press
 Ctrl-D (or, I think, Ctrl-Z if you are using MS-Windows).
 
 However, the os.read() function will only read what is currently
 available.  Note, though, that os.read() does not do line-based
 I/O, so depending on the timing you can get incomplete lines, or
 multiple lines in one read.
 
 
be carefull that you specify how much you want to read at a time, 
otherwise it cat be that you keep on reading.

Specify read(1024) or somesuch.

In case of my PPCEncoder I recompiled the mencoder subprocess to deliver 
me lines that end with \n.

If anyone can tell me how to read a continues stream than I am really 
interested.

cya
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: interested????

2008-02-05 Thread Ivo
no
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple HTML template engine?

2007-10-15 Thread Ivo
Ciprian Dorin Craciun wrote:
 Have you tried CherryPy? http://www.cherrypy.org/
 
 It's not a template engine, but a simple web server engine, and
 you could code your conditionals and loops directly in Python... When
 I have tried it, it looked very nice and easy.
 
 Ciprian.
 
 
 On 10/15/07, allen.fowler [EMAIL PROTECTED] wrote:
 Hello,

 Can anyone recommend a simple python template engine for generating
 HTML that relies only on the Pyhon Core modules?

 No need for caching, template compilation, etc.

 Speed is not a major issue.

 I just need looping and conditionals. Template inheritance would be a
 bonus.

 I've seen Genshi and Cheetah, but they seem way too complex.

 Any ideas?

 I'm sure I could build something myself, but I'm sure this has already
 been done quite a few times.  Why re-invent the wheel, right?


 Thank you,
 Allen

I concur completely!
My site http://IvoNet.nl is completely written in python and based on a 
very early release of cherrypy.

gr,
Ivo.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Regex Question

2007-09-21 Thread Ivo
crybaby wrote:
 On Sep 20, 4:12 pm, Tobiah [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
 I need to extract the number on each td tags from a html file.
 i.e 49.950 from the following:
 td align=right width=80font size=2 face=New Times
 Roman,Times,Serifnbsp;49.950nbsp;/font/td
 The actual number between: nbsp;49.950nbsp; can be any number of
 digits before decimal and after decimal.
 td align=right width=80font size=2 face=New Times
 Roman,Times,Serifnbsp;##.nbsp;/font/td
 How can I just extract the real/integer number using regex?
 '[0-9]*\.[0-9]*'

 --
 Posted via a free Usenet account fromhttp://www.teranews.com
 
 I am trying to use BeautifulSoup:
 
 soup = BeautifulSoup(page)
 
 td_tags = soup.findAll('td')
 i=0
 for td in td_tags:
 i = i+1
 print td: , td
 # re.search('[0-9]*\.[0-9]*', td)
 price = re.compile('[0-9]*\.[0-9]*').search(td)
 
 I am getting an error:
 
price= re.compile('[0-9]*\.[0-9]*').search(td)
 TypeError: expected string or buffer
 
 Does beautiful soup returns array of objects? If so, how do I pass
 td instance as string to re.search?  What is the different between
 re.search vs re.compile().search?
 

I don't know anything about BeautifulSoup, but to the other questions:

var=re.compile(regexpr) compiles the expression and after that you can 
use var as the reference to that compiled expression (costs less)

re.search(expr, string) compiles and searches every time. This can 
potentially be more expensive in calculating power. especially if you 
have to use the expression a lot of times.

The way you use it it doesn't matter.

do:
pattern = re.compile('[0-9]*\.[0-9]*')
result = pattern.findall(your tekst here)

Now you can reuse pattern.

Cheers,
Ivo.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remote Command a Python Script

2007-09-21 Thread Ivo
Ulysse wrote:
 Hello,
 
 I've installed Python 2.5 on my WRT54G Linksys Router. On this router
 a script is executed. This script write a little Pickle database in
 the router memory.
 
 I would like to write another Python script which will be able to :
 
 1. Stop and start the remote script from my Windows Computer. At
 present I use Putty to connect to the router by the SSL, then I
 manually kill the python process.
 
 2. Retrieve the little database located in router memory and backup it
 on my Window PC. At present I use WinSCP (like FTP) to get the pickle
 file.
 
 Can you help me with that (modules to use, useful code snippets)
 
 Thank a lot,
 
 Maxime
 
or SPyRO
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: elementtree question

2007-09-21 Thread Ivo
Tim Arnold wrote:
 Hi, I'm using elementtree and elementtidy to work with some HTML files. For 
 some of these files I need to enclose the body content in a new div tag, 
 like this:
 body
   div class=remapped
original contents...
   /div
 /body
 
 I figure there must be a way to do it by creating a 'div' SubElement to the 
 'body' tag and somehow copying the rest of the tree under that SubElement, 
 but it's beyond my comprehension.
 
 How can I accomplish this?
 (I know I could put the class on the body tag itself, but that won't satisfy 
 the powers-that-be).
 
 thanks,
 --Tim Arnold
 
 

You could also try something like this:

from sgmllib import SGMLParser
class IParse(SGMLParser):
 def __init__(self, verbose=0):
 SGMLParser.__init__(self, verbose)
 self.data = 
 def _attr_to_str(self, attrs):
 return ' '.join(['%s=%s' % a for a in attrs])

 def start_body(self, attrs):
 self.data += body %s % self._attr_to_str(attrs)
 print remapping
 self.data += '''div class=remapped'''
 def end_body(self):
 self.data += /div # end remapping
 self.data += /body
 def handle_data(self, data):
 self.data += data
 def unknown_starttag(self, tag, attrs):
 self.data+=%s %s % (tag,  self._attr_to_str(attrs),)
 def unknown_endtag(self, tag):
 self.data += /%s % tag


if __name__==__main__:
 i = IParse()
 i.feed('''
html
 body bgcolor=#f
 original
 iitalic/i
 b class=testcontents/b...
 /body
/html''');

 print i.data
 i.close()


just look at the code from sgmllib (standard lib) and it is very easy to 
make a parser. for some much needed refactoring

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Resolving windows shortcut to url

2007-09-21 Thread Ivo
Ivo wrote:
 Richard Townsend wrote:
 If I have a windows shortcut to a URL, is there a way to get the URL
 in a Python app?

 I found some code that uses pythoncom to resolve shortcuts to local
 files, but I haven't found any examples for URLs.

 The PyWin32 help mentions the PyIUniformResourceLocator Object, but I
 couldn't find an example of how to use it.

 do you mean a *.lnk file or a *.url file?

for a link (*.lnk) file:


from win32com.shell import shell
import pythoncom
import os, sys

class PyShortcut(object):
 def __init__(self):
 self._base = pythoncom.CoCreateInstance(shell.CLSID_ShellLink,
 None,
 
pythoncom.CLSCTX_INPROC_SERVER,
 shell.IID_IShellLink)

 def load(self, filename):
 
self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)

 def save(self, filename):
 
self._base.QueryInterface(pythoncom.IID_IPersistFile).Save(filename, 0)

 def __getattr__(self, name):
 if name != _base:
 return getattr(self._base, name)


if __name__==__main__:
 lnk = PyShortcut()
 lnk.load(path to your shortcut file including the .lnk extention 
even if you don't see it in windows)
 print Location:, lnk.GetPath(shell.SLGP_RAWPATH)[0]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Resolving windows shortcut to url

2007-09-21 Thread Ivo
Richard Townsend wrote:
 If I have a windows shortcut to a URL, is there a way to get the URL
 in a Python app?
 
 I found some code that uses pythoncom to resolve shortcuts to local
 files, but I haven't found any examples for URLs.
 
 The PyWin32 help mentions the PyIUniformResourceLocator Object, but I
 couldn't find an example of how to use it.
 
do you mean a *.lnk file or a *.url file?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Resolving windows shortcut to url

2007-09-21 Thread Ivo
Ivo wrote:
 Richard Townsend wrote:
 If I have a windows shortcut to a URL, is there a way to get the URL
 in a Python app?

 I found some code that uses pythoncom to resolve shortcuts to local
 files, but I haven't found any examples for URLs.

 The PyWin32 help mentions the PyIUniformResourceLocator Object, but I
 couldn't find an example of how to use it.

 do you mean a *.lnk file or a *.url file?

if an *.url file just open it as a properties file (ConfigParser) 
because it looks something like:


[InternetShortcut]
URL=http://ivonet.nl/
IDList=
IconFile=http://ivonet.nl/favicon.ico
IconIndex=1
[{000214A0---C000-0046}]
Prop3=19,2

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Database Apps

2007-09-11 Thread Ivo
[EMAIL PROTECTED] wrote:
 Kindof a poll, kindof curiosity...
 
 What is your favorite python - database combination?  I'm looking to
 make an app that has a local DB and a server side DB.  I'm looking at
 python and sqlite local side and sql server side.
 
 Any suggestions
 
 Darien
 
If you like to make a kind of stand alone app with a database, SQLite a 
good choice. It is easy to embed into your app. If you keep to ANSI SQL 
there should be no trouble changing databases at a later date.
I use SQLite for my WebSite http://IvoNet.nl and it performs great.
The whole database is less than 1Mb including the SQLite module for 
python. No 50Mb install needed if you just want a simple database.
It makes my website very portable and easy to install.

MySQL works great to. I have used it a lot and it is very available. 
Just about every provider can provide you one.

Ivo.
-- 
http://mail.python.org/mailman/listinfo/python-list


New PPCEncoder available (v00.34)

2006-04-18 Thread Ivo
PPCEncoder The xViD encoder for a PocketPC like aparatus has new
features.
- IconTray in minimize
- Set Processing priority. Very handy If you want to convert movies and
still be able to work on you PC during the conversion

This application Encodes video to PocketPC DivX format and size.
With PPCEncoder you can encode and optimize your movies for the size of
your PocketPC screen and memory card

Check it out here: http://IvoNet.nl

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Relative paths in mod_python

2006-03-20 Thread Ivo van der Sangen
On 2006-03-19, Bruno Desthuilliers [EMAIL PROTECTED] 
wrote:
 Ivo van der Sangen a écrit :
 I was wondering if I could use relative paths in a mod_python script. At
 the moment I am defining a constant string
 /path/to/dir/where/script/resides. The problem with this is that when
 I move the script including files I use to get metadata I have to change
 this variable. The same problem occurs when I distribute the script; the
 person using it will first have to modify it, which is not what I want. Is
 it possible that a mod_python script has as current working directory
 the directory where the script resides? At the moment os.getcwd()
 returns '/'.

 You could set this constant in the apache conf as a PythonOption. And/Or 
 you could post this question to mod_python's mailing list !-)

I wasn't aware of the mod_python list. The next time I will post my
question there, but I don't think I will get a better answer there; the
solutions given here so far are fine.
-- 
http://mail.python.org/mailman/listinfo/python-list


Relative paths in mod_python

2006-03-19 Thread Ivo van der Sangen
I was wondering if I could use relative paths in a mod_python script. At
the moment I am defining a constant string
/path/to/dir/where/script/resides. The problem with this is that when
I move the script including files I use to get metadata I have to change
this variable. The same problem occurs when I distribute the script; the
person using it will first have to modify it, which is not what I want. Is
it possible that a mod_python script has as current working directory
the directory where the script resides? At the moment os.getcwd()
returns '/'.
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess.Popen() redirecting to TKinter or WXPython textwidget???

2005-01-26 Thread Ivo Woltring
Hi Pythoneers,

I am trying to make my own gui for mencoder.exe (windows port of the
terrific linux mencoder/mplayer) to convert divx to Pocket_PC size.
My current app creates a batch script to run the mencoder with the needed
params, but now I want to integrate mencoder as a subprocess in my app.

What already works:
the starting of the subprocess.Popen
and the subsequent killing of the process if I want it to.
My gui does not freeze up as it did in my first tries.

What I want to know (what does not yet work ;-)):
- Redirecting the output of the subprocess to a textwidget in my GUI

Any example or help is much appreceated.

I tried the subprocess.PIPE but I think I don't really understand how it is
suppost to work
The redirecting to a file does work but this not my objective...
So I'm stuck. HELP
The started processes are long and I want to be able to show some kind of
progress-status.

Thanx,
Ivo Woltring


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen() redirecting to TKinter or WXPython textwidget???

2005-01-26 Thread Ivo Woltring

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Ivo, my initial thought would be, you need to know how much text you
 will get back from popen.  My Python reference has the following
 example:

 import os
 dir = os.popen('ls -al', 'r')
 while (1):
 line = dir.readline()
 if line:
 print line,
 else:
 break

 that example shows how to capture the process output in a file-type
 object, then bring it into a string with readline().

[ snip ]
 cheers
 S



Thanx for trying Stewart,
 but that is not what I need
The output of mencoder is not readable with readlines (i tried it) because
after the initial informational lines You don't get lines anymore (you get a
linefeed but no newline)
The prints are all on the same line (like a status line)
something like
Pos:   3,1s 96f ( 0%)  42fps Trem:   0min   0mb  A-V:0,038 [171:63]

which is coninually updated while the process runs...

 in your app, you could create a Tkinter stringVar, say myOutput, for
 the process output. In your Tkinter widget, you could then set a
 textvariable=myOutput. also use the wait_variable and watch options

How does this work? wait?? anyone?

 (hope I recall these correctly, don't have my Tkinter ref. at hand) to
 detect when there's been a change to the contents of the StringVar and
 update the contents of the label.
 Hope this helps, if not, write back.

I really like to know how I can catch the output of a subproces.Popen()
command and redirect it to something else (like a textwidget )
and I really like to use the subprocess module (standard in v2.4) to get to
know it.
Another reason to use the subprocess module is I can stop the process
because I know the handle of the thread. The subprocess module knows all
this.

cheerz,
Ivo.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MP3 - VBR - Frame length in time

2004-12-12 Thread Ivo Woltring

Florian Schulze [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Sat, 11 Dec 2004 20:32:30 +0100, Ivo Woltring [EMAIL PROTECTED]
 wrote:

  mmpython will help but not always.
  Lets put it this way. I will ALWAYS read through the whole file. In that
  order I don't mind evaluating each frame. The thing I don't seem to be
  able
  to find is the timelength-constants for frames for the different mp3
  versions, bitrates and layers. Can anybody help me?

  From http://www.oreilly.com/catalog/mp3/chapter/ch02.html#71109
 In addition, the number of samples stored in an MP3 frame is constant, at
 1,152 samples per frame.


 So you only need the samplerate for each frame to calculate the duration
 of that frame.

 1152 samples / 44100 samples per second ~ 0.026 seconds

 I don't exactly know whether you need to include mono/stereo into the
 calculation, you would have to test that out.

 Regards,
 Florian Schulze

thanks!
will try this out
Greetz,
Ivo.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MP3 - VBR - Frame length in time

2004-12-11 Thread Ivo Woltring

JanC [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Dmitry Borisov schreef:

  It has something to deal with the VBR tags( XING header ).

 *If* there is a VBR tag (it's a custom extension) and *if* that VBR tag
 contains a correct value.


 -- 
 JanC

 Be strict when sending and tolerant when receiving.
 RFC 1958 - Architectural Principles of the Internet - section 3.9

mmpython will help but not always.
Lets put it this way. I will ALWAYS read through the whole file. In that
order I don't mind evaluating each frame. The thing I don't seem to be able
to find is the timelength-constants for frames for the different mp3
versions, bitrates and layers. Can anybody help me?

Thnaks,
Ivo


-- 
http://mail.python.org/mailman/listinfo/python-list


MP3 - VBR - Frame length in time

2004-12-08 Thread Ivo Woltring
Dear Pythoneers,

I have this problem with the time calculations of an VBR (variable bit rate)
encoded MP3.
I want to make a daisy writer for blind people. To do this I have to know
exactly what the length in time of an mp3 is. With CBR encoded files I have
no real problems (at least with version 1 and 2), but with VBR encoded I get
into trouble.
I noticed that players like WinAMP and Windows Media player have this
problem too.
I don't mind to have to read the whole mp3 to calculate, because performance
is not a real issue with my app.

Can anyone help me? I am really interested in technical information on VBR
and MP3.
Can anybody tell me the length in time of the different bitrates in all the
versions of mp3 and all the layers.

Tooling or links also really welcome. My own googling has helped me some but
on the subject of VBR I get stuck.

Thanks a lot,
Ivo.


-- 
http://mail.python.org/mailman/listinfo/python-list