Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'context': 0.05; 'discard': 0.05; 'filename': 0.07; 'filenames': 0.07; 'responding': 0.07; 'python': 0.09; 'before.': 0.09; 'corresponds': 0.09; 'event):': 0.09; 'here?': 0.09; 'newest': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'gui': 0.11; 'thread': 0.11; 'assume': 0.11; 'yet.': 0.13; 'stack': 0.15; 'anyways,': 0.16; 'cc:name:python list': 0.16; 'count.': 0.16; 'increment': 0.16; 'least.': 0.16; 'replaces': 0.16; 'stream.': 0.16; 'subject:GUI': 0.16; 'subject:image': 0.16; 'subprocess': 0.16; 'there?': 0.16; 'thread-safe': 0.16; 'threaded': 0.16; 'thanks,': 0.18; '(or': 0.18; 'load': 0.19; 'file.': 0.20; 'trying': 0.21; 'do.': 0.21; 'earlier': 0.21; 'displayed': 0.22; 'sorry,': 0.22; 'absolute': 0.23; "haven't": 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'skip:m 30': 0.26; 'cc:addr:gmail.com': 0.27; 'older': 0.27; 'question': 0.27; 'newer': 0.27; 'there.': 0.28; 'this?': 0.28; 'chris': 0.28; 'reply.': 0.28; 'far.': 0.29; 'included': 0.29; 'class': 0.29; 'that.': 0.30; 'actively': 0.30; 'checks': 0.30; 'figure': 0.30; '(and': 0.32; 'url:python': 0.32; 'file': 0.32; 'could': 0.32; 'directory,': 0.33; 'real-time': 0.33; 'zero': 0.33; 'likely': 0.33; 'monitor': 0.33; 'tutorial': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'updated': 0.34; 'needed': 0.35; 'mapping': 0.35; 'replaced': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'created': 0.36; 'but': 0.36; 'url:org': 0.36; 'anything': 0.36; 'should': 0.36; 'being': 0.37; 'passed': 0.37; 'previous': 0.37; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'some': 0.38; 'things': 0.38; 'delete': 0.38; 'takes': 0.39; 'google': 0.39; 'list,': 0.39; 'think': 0.40; 'from:no real name:2**0': 0.60; 'most': 0.61; 'matter': 0.61; 'latest': 0.61; 'kind': 0.61; 'back': 0.62; 'more': 0.63; 'replying': 0.64; 'notified': 0.65; 'url:6': 0.65; 'url:0': 0.67; 'forth': 0.75; '(yes,': 0.84 X-Received: by 10.49.75.195 with SMTP id e3mr521456qew.24.1360343371452; Fri, 08 Feb 2013 09:09:31 -0800 (PST) Newsgroups: comp.lang.python Date: Fri, 8 Feb 2013 09:09:31 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=155.92.68.198; posting-account=Nf-8OgoAAACfxrvtm6NEcWRhvoTaS5A2 References: <8a572770-9cc1-4b65-9053-10fd6c2f543b@googlegroups.com> <02bee1ed-1a9b-4cac-975a-098b3382250f@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 155.92.68.198 MIME-Version: 1.0 Subject: Re: Monitoring updating directory for image for GUI From: ciscorucinski@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Python List , ciscorucinski@gmail.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 89 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360343379 news.xs4all.nl 6964 [2001:888:2000:d::a6]:50435 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38465 > Who/what are you responding to here? You haven't included any context > from what you're replying to. Sorry, never really used Google Groups, or anything like this before. That = I was responding to only Chris Angelico with his question of how real-time = it needed to be...since it takes some time for Lilypond to create the image= s. > So you have a thread that updates the image and then checks the stack > to see if a new image is available? Can you not just have it only try > to load the newest image? That is what I am trying to figure out how to do. I have a counter that upd= ates with every note that is grabbed from the stream. That counter is passe= d into a threaded class that might or might not create the image right away= ...but seems to create them sequentially from what I have seen so far (I do= n't know if that is absolute thought).=20 Please let me know you thought on the above part! Each new thread should on= ly take only a very small amount longer to do than the previous thread that= was started...because it has one more note to deal with this time. Anyways...I do have the count of the latest image that WILL BE created...bu= t by the time that one is created in the directory, a new note is most like= ly streamed in and replaces that count. Therefore, I cannot really do that.= ..I think. hmmmm, I wonder. I create the images via OS command that will .wait() on a = subprocess.Popen(). I could increment the counter there? Or do something th= ere that will let me know of the most recent image file via a counter or so= mething? But it needs to be thread-safe > You say that you control the filenames of the images. I assume that > you are notified when a file is created and given the filename of the > new file. So you can maintain a mapping of filename->ordering. In this > case you can determine when a file notification arrives whether the > filename corresponds to a more recent note than the filename that is > currently waiting to be displayed (or is currently displayed). If it > is an older note then discard it (and delete the file?) when the > notification arrives. If it is newer then discard the one that is > currently waiting to be displayed. This way there are always either > zero or one filenames waiting and if there is one then it is the most > recent one seen so far. I am not notified when the file is created...but like I said before, I wait= on the subprocess and could do something there. > Is that using something like watchdog? > http://pypi.python.org/pypi/watchdog I don't know about Watchdog...but from an earlier version of a tutorial onl= ine... http://pypi.python.org/pypi/watchdog/0.3.6 (Yes, it is currently on v0.6.0= and this is older - v0.3.6) ... it looks like I COULD do something like... class MyEventHandler(FileSystemEventHandler): ... ... def on_created(self, event): # update gtkImage object here!! ...right? Or no? I will say that I kind of like that. The only thing is, do= you think that would "flicker" in the GUI if a bunch of new images are cre= ated in quick succession? Anyways, I think that would be the most desired o= utcome...with every image being used and replaced with something newer with= out a large lag...as it will happen during each creation of a new image.=20 > It matters for how you monitor the directory at least. My other question, if I do monitor the directory vs. use a queue, or stack = / list, is how to monitor a directory that is actively being updated while = I search for the file. This might not matter and something like os.walk() m= ight work...I don't know, I don't know python that well yet. Do you get what I mean with this? Sorry if something seems out of place...I was going back and forth and addi= ng / removing things to my reply. Thanks, Christopher