Steve Holden wrote:
> Ritesh Raj Sarraf wrote:
>> On Aug 16, 12:16 am, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote:
>>> On Aug 15, 11:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>>>
> [...]
>> Oops!!! Looks like I completely missed this. It _did_
On Aug 16, 12:16 am, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote:
> On Aug 15, 11:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
> > On 2007-08-15, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote:
> > > Or am I terribly missing something that you are trying
On Aug 15, 11:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-08-15, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote:
> > Or am I terribly missing something that you are trying to tell ?
>
> I didn't see log = Log() in your example. Sorry for the
> exc
Neil Cerutti wrote:
>>
>> Doesn't __init__ get called automatically ?
>
> It gets called automatically when you construct an instance of
> the class in which it's defined.
I am a little confused by your statements now.
In my earlier posts in the same thread, I gave some code example which was
s
Neil Cerutti wrote:
> If you want an import inside an __init__ to run, you must call
> the __init__ function that contains it.
Doesn't __init__ get called automatically ?
I thought __init__ was required to be called explicitly only when you were
doing inheritance and wanted to pass separate value
Bruno Desthuilliers wrote:
>>> What's leading you to conclude the import isn't being executed? You
>>> realise, I trust, that the module's code will only be executed on the
>>> first call to __init__()?
>>>
>>
>> Well. Putting it in a "try" inside __init__() doesn't do anything.
>
> This would b
Steve Holden wrote:
> Ritesh Raj Sarraf wrote:
>> class Log:
>>
>> def __init__(self, verbose, lock = None):
>>
>> if verbose is True:
>> self.VERBOSE = True
>> else: self.VERBOSE = False
>>
> Better:
>
Bruno Desthuilliers wrote:
> Ritesh Raj Sarraf a écrit :
>
> The initializer will be called *each time* you instanciate the class.
> And nothing prevents client code from calling it explicitelly as many
> times as it wants - ok, this would be rather strange, but this is stil
Bruno Desthuilliers wrote:
> Ritesh Raj Sarraf a écrit :
>>
>> if lock is None or lock != 1:
>> self.DispLock = False
>> else:
>> self.DispLock = threading.Lock()
>> self.lock = T
On Aug 11, 3:17 am, James Stroud <[EMAIL PROTECTED]> wrote:
> You do realize your import statement will only be called for nt and dos
> systems don't you?
>
Yes. I would like to load a Windows Python Module (which is, say a
specific implementation for Windows only) in such a condition where I
find
Hi,
I've been very confused about why this doesn't work. I mean I don't see any
reason why this has been made not to work.
class Log:
def __init__(self, verbose, lock = None):
if verbose is True:
self.VERBOSE = True
else: self.VERBOSE = False
if lock is
Hi,
I need a little help in understanding how Namespaces and scoping works with
Classes/Functions in Python.
Here's my code:
class FetchData:
def __init__(self, dataTypes=["foo", "bar", "spam"], archive=False):
self.List = []
self.Types = dataTypes
if
ompletion or thread debugging, all is supported. For
multithreaded applications, in PyDev, you'll see all the threads listed.
Then you can use each thread and proceed with debugging the code.
Learning Eclipse might take some time but that's worth it.
HTH,
Ritesh
--
Ritesh Raj S
And that I do is because the output can be huge and useless.
Then I do some pattern matching on that file and filter my data and then delete
it.
If you think I still am missing something important, request you to describe it.
Thanks,
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.r
it out.
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."
"Stealing logic from one person is plagiarism, stealing from many is research."
"The great are those who achieve the impossible, the petty are those who
cannot -
27;t think the
environment variable is going to be the same.
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."
"Stealing logic from one person is plagiarism, stealing from many is research."
"The great are those w
Gabriel Genellina wrote:
> En Thu, 15 Mar 2007 18:31:29 -0300, Ritesh Raj Sarraf <[EMAIL PROTECTED]>
> escribió:
>
>> I'm not sure if there's something wrong in the code mentioned above or
>> is it
>> really a lock problem.
>
> Try to break
e above code, "aa" is the first string which will be executed in
Thread-1. In my query to the ldap server, I am getting a record which matches
the "aa" string. I've verified it by putting a breakpoint and checking the
value.
The problem is that when I run the program manua
wnloads on a single line. Probably the apt developers also
might have run into the same issue and hence settled down with this
workaround.
Thanks,
Ritesh
Dennis Lee Bieber wrote:
> On Tue, 28 Nov 2006 15:15:28 +0530, Ritesh Raj Sarraf
> <[EMAIL PROTECTED]> declaimed the followi
or each separate progress action.
Thanks,
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."
"Stealing logic from one person is plagiarism, stealing from many is
research."
"The great are those who achieve the impo
Hi,
I have, for very long, been trying to find a consistent solution (which
could work across major python platforms - Linux, Windows, Mac OS X)
for the following problem.
I have a function which downloads files from the web. I've made the
function threaded. I'm trying to implement a progress bar
e a couple of seconds for the zip to
complete. During those couple of seconds, if another thread's file (a
couple kb) gets downloaded/copied, will it wait for the lock to be
released or will it create another lock ?
Thanks,
Ritesh
Dennis Lee Bieber wrote:
> On Wed, 11 Oct 2006 18:39:32
pping even if that's not true.
My question is, in a code example like this which is threaded, does the locking
mechanism work correctly ?
Or are two different locks being acquired ?
Thanks,
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of i
ke you only created one progress bar, and each
> thread is referencing that single bar. I'd suspect you need to create a
> bar for EACH thread you create, and tell the thread which bar to update.
Yes, you're correct. That's what I'm also suspecting. I tried to do s
progress bar gets over-written by
the download progress of files from other threads.
I believe my change has to go into the progress bar class to make it thread
aware.
Are they any docs/suggestions on how to implement progress bars along with
threads ?
Thanks,
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT
y need to be using the same
> lock.
>
> Try moving "ziplock = threading.Lock()" out of the function, so
> your code might read, in part:
>
>
> ziplock = threading.Lock()
>
> def run(request, response, func=copy_first_match):
> # And so on...
Thank
finally:
ziplock.release()
elif exit_status == True:
if zip_bool:
ziplock.acquire()
try:
compress_the_file(zip_type_file, sFile, sSourceDir)
Carl Banks wrote:
>
> Exactly. Only one thread can hold a lock at a time. If a thread tries
> to acquire a lock that some other thread has, it'll wait until the
> other thread releases it. You need locks to do this stuff because most
> things (such as zipfile objects) don't wait for other threa
Carl Banks wrote:
> If you have multiple threads trying to access the same ZIP file at the
> same time, whether or not they use the same ZipFile object, you'll have
> trouble. You'd have to change download_from_web to protect against
> simultaneous use. A simple lock should suffice. Create the
Gerhard Fiedler wrote:
> Rather than downloading and zipping in the same thread, you could run
> multiple threads like you're doing that only download files, and one
> zip-it-all-up thread. After downloading a file, the download threads place
> a message in a queue that indicates the file they hav
Simon Forman wrote:
>
> The other threads will just take the next request from the Queue and
> process it. They won't "care" what the one thread is doing,
> downloading, zipping, whatever.
>
As I mentioned in my previous post, the other threads will also have to
go through the same "zip the file
Simon Forman wrote:
> > One other question I had,
> > If my user passes the --zip option, download_from_web() internally (when the
> > download is successful) zips the downloaded data to a zip file. Since in
> > case
> > of threading there'll be multiple threads, and say if one of the thread
> >
rk ?
Thanks,
Ritesh
Justin Azoff on Thursday 27 Jul 2006 22:33 wrote:
> Ritesh Raj Sarraf wrote:
> [snip]
>> for item in list_items:
>> download_from_web(item)
>>
>> This way, one items is downloaded at a time.
>>
>> I'm planning to implement thr
sing the requestQueue()
And in function run(), when the item of lRawData is None, the thread stops.
The the cleanup and checks of any remaining threads is done.
Is this all correct ?
I also do have a couple of questions more which would be related to locks. But
I'd post them once I get do
And people, Is there any documentation on Python Threads or Threads in general.
It'd be of great help to really understand.
Ritesh
Ritesh Raj Sarraf on Thursday 27 Jul 2006 16:37 wrote:
> Is this the correct way of threading applications ?
> This is the first time I'd be doing t
e_response(response)
>
I guess these would be clear once I'm clear on the first problem.
> # and then to shut down the threads when you've finished:
> for t in thread_pool:
> requestQueue.put(None)
> for t in thread_pool:
> t.join()
Thanks a lot for your replies.
Ri
ds[i].start()
counter += 1
i += 1
counter = 0
join_i = i - 3
while counter < 3:
threads[join_i].join()
counter += 1
join_i += 1
Is this correct ? Comments!!
Ritesh
Duncan Booth wrote:
> Ritesh
Hi,
I have some basic doubts about thread.
I have a list which has items in it which need to be downloaded from
the internet.
Let's say list is:
list_items[] which has 100 items in it.
I have a function download_from_web() which does the work of
downloading the items from the web. It does error
> > log = foo.log(x, y, z)
> >
Resulting line is:
log = foo.log(x, y, z)
global log
Making the instance "log" global makes it accessible to all the
functions.
Now I have only one question, Is this a correct way to do it ? Or are
there better way ?
Ritesh
--
http://mail.python.org/mailman/list
Steve Holden wrote:
> Ritesh Raj Sarraf wrote:
> > But when I call the same method from some functions which are in
> > bar.py, it fails giving me the following error:
> >
> > NameError: global name 'log' is not defined
> >
> Well, that's
Hi,
I have a class defined in a file called foo.py
In bar.py I've imported foo.py
In bar.py's main function, I instantiate the class as follows:
log = foo.log(x, y, z)
Now in main I'm able to use log.view(), log.error() et cetera.
But when I call the same method from some functions which are i
Peter Otten wrote:
> You can achieve the desired behaviour by adding a custom Filter:
>
> import sys
> import logging
>
> logger = logging.getLogger("my_app")
> logger.setLevel(logging.DEBUG)
>
> class LevelFilter(logging.Filter):
> def __init__(self, level):
> self.level = level
>
Vinay Sajip wrote:
>
> It's usual to rely on logger levels and to set handler levels for
> additional refinement of what goes to a particular handler's
> destination.
>
The problem is that for StreamHandler, logging module logs to
sys.stderr.
I want to use the logging feature for most of the mess
Ritesh Raj Sarraf wrote:
> import os, sys, logging
>
> logger = logging.getLogger("my_app")
>
I tried this code:
import logging, sys
# set up logging to file - see previous section for more details
logging.basicConfig(level=logging.DEBUG,
format=
amHandler(sys.stdout)
console.setLevel(logging.INFO)
console_formatter = logging.Formatter('%(message)s')
console.setFormatter(console_formatter)
logger.addHandler(conerr)
logger.addHandler(console)
logger.info("Ritesh Raj Sarraf.\n")
logger.warning("Ricky Raj Sarraf.\n")
H
Hi,
The program downloads the files from the internet and compresses them
to a single zip archive using compress_the_file().
Upon running syncer() which calls the decompress_the_file(), the first
iteration succeeds. But upon second iteration, I get an IOError
exception with the message:
"compress
Fredrik Lundh wrote:
> Ritesh Raj Sarraf wrote:
>
> >> http://docs.python.org/lib/optparse-standard-option-actions.html
> >
> > That won't help because by design of my program, I can't limit the
> > number of arguments a user can pass to it.
>
>
Simon Percivall wrote:
>
> It might do you good to read the documentation instead of blindly
> experimenting.
>
> Anyway,
>
> parser.add_option("", "--my-option", nargs=3)
>
> http://docs.python.org/lib/optparse-standard-option-actions.html
That won't help because by design of my program, I can't
Ritesh Raj Sarraf wrote:
> I just noticed that the args variable is holding values b and c.
> the args variables comes from:
> (options, args) = parser.parse_args()
>
> I guess I only need to figure out now is why args isn't storing
> argument "a" also..
Ritesh Raj Sarraf wrote:
> Hi,
>
> I'm having some minor problems with optparse. I'm just worried that
> someone shouldn't say that multiple argument feature isn't implemented
> in optpartse.
>
> How to tackle multiple arguments to an option ?
> As fa
Hi,
I'm having some minor problems with optparse. I'm just worried that
someone shouldn't say that multiple argument feature isn't implemented
in optpartse.
How to tackle multiple arguments to an option ?
As far as I dug, I've found that >1 arguments are being ignored.
parser.add_option("", "--m
Hi,
I've got a problem here.
def compress_the_file(zip_file_name, files_to_compress, sSourceDir):
"""
Condenses all the files into one single file for easy transfer
"""
try:
import zipfile
except ImportError:
sys.stderr.write("Ai! module not found.\n")
Also,
f = file ('some_file.jpg')
throws an error.
"str object is not callable"
Ritesh
Maric Michaud wrote:
> Le Mercredi 14 Juin 2006 11:22, Ritesh Raj Sarraf a écrit :
> > Hi,
> >
> > I have a funtion named unzipper() which does the work of unzipping th
But isn't there any library function ?
Something like
XX.filetype(name)
Directory
File-Tar
File-Zip
File-MPEG
Ritesh
Maric Michaud wrote:
> Le Mercredi 14 Juin 2006 11:22, Ritesh Raj Sarraf a écrit :
> > Hi,
> >
> > I have a funtion named unzipper() which does
Hi,
I have a funtion named unzipper() which does the work of unzipping the
files.
Is there a way I can identify what is the type of the file which'll be
passed to unzipper().
If yes, I'll be able to make out if it's a zip file or a tar or a bz2
file.
Thanks,
Ritesh
--
http://mail.python.org/ma
Can you please point some good documents (need not be Python specific)
on best practices with writing code this way ?
Thanks,
Ritesh
--
http://mail.python.org/mailman/listinfo/python-list
Thanks to everyone. It is really the best place and the best people to
learn from.
Here's what I followed from the discussion:
def files(root):
for path, folders, files in os.walk(root):
for file in files:
yield path, file
def copy_first_match(repository, filename, dest_d
Hi,
Following is the code:
def walk_tree_copy(sRepository, sFile, sSourceDir, bFound = None):
try:
if sRepository is not None:
for name in os.listdir(sRepository):
path = os.path.join(sRepository, name)
if os.path.isdir(path):
"\n"
data.close()
temp.close()
Thanks,
Ritesh
Ritesh Raj Sarraf on Sunday 15 Jan 2006 12:55 wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi,
>
> In urllib.urlretrieve I can use reporthook to implement a progress bar.
>
> But in
pm"
sUrl="http://localhost/new.rpm";
urllib.urlretrieve(sUrl, sFile, reporthook=myReportHook)
print "\n\n"
#temp = urllib2.urlopen(sUrl)
#lastval = int(temp.headers['Content-Length'])
#prog = progressBar(0, lastval, 77)
#
#for x in range(101):
#prog.updateAm
imal or full or blah.
For this I think this should be enough:
if not options.set_upgrade and options.upgrade_type:
parser.error("They are mutually inclusive options")
But my main concern is what if the user doesn't pass any arguemtns. Every
option I have has a default
On Tue, 6 Dec 2005, Peter Otten wrote:
> Ritesh Raj Sarraf wrote:
>
>> I'm using this for "option arguments" which are mutually inclusive.
>> But I want the user to pass atleast one "option argument" for the program
>> to function properly.
&g
fetch-update" option, it should execute the
required code. Now how do I check if at least one option has been passed at
the command-line ?
I have multiple options but I have parser.set_defaults() for each of them.
Regards,
rrs
- --
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.c
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Marc 'BlackJack' Rintsch on Monday December 5 2005 03:24 wrote:
> In <[EMAIL PROTECTED]>, Ritesh Raj
> Sarraf wrote:
>
>> My program uses mostly "option arguments" hence my len(args) value is
>> alwa
nts". Something like:
(options,args) = parser.parse_args()
len(options) != 1 or len(options) > 2:
print "Incorrect number of arguments passed."
How do I accomplish it ?
Regards,
rrs
- --
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
"Stealing logics from o
Windows/Mac OSX/Linux et
cetera. That is why I'm sticking strictly to python libraries.
The second suggestion sounds good. I'll look into that.
Thanks,
rrs
- --
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
Gnupg Key ID: 04F130BC
"Stealing logic from one person is plagia
he desired file.
I think my problem is fixable in urllib.urlopen, I just find
urllib.urlretrieve more convenient and want to know if it can be done with
it.
Thanks for responding.
rrs
- --
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
Gnupg Key ID: 04F130BC
"Stealing logic from o
here is no
package named libparl5.6
Please Help!
rrs
- --
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
Gnupg Key ID: 04F130BC
"Stealing logic from one person is plagiarism, stealing from many is
research".
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.5 (GNU/Linux)
i
68 matches
Mail list logo