Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'interfaces': 0.04; 'encoding': 0.05; 'explicitly': 0.05; 'assuming': 0.09; 'filenames': 0.09; 'library?': 0.09; 'logic': 0.09; 'option,': 0.09; 'spec': 0.09; 'stating': 0.09; 'trailing': 0.09; 'url:github': 0.09; 'whichever': 0.09; 'windows,': 0.09; 'runs': 0.10; 'subject:How': 0.10; 'python': 0.11; 'wrote': 0.14; 'changes': 0.15; 'chris,': 0.16; 'golden': 0.16; 'length.': 0.16; 'monitors': 0.16; 'specifying': 0.16; 'statistics.': 0.16; 'subject:Problem': 0.16; 'terms:': 0.16; 'url:py': 0.16; 'url:timgolden': 0.16; 'folder': 0.16; 'wrote:': 0.18; 'module': 0.19; 'file,': 0.19; 'thoughts': 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'comparing': 0.24; 'directory.': 0.24; 'mind.': 0.24; 'specify': 0.24; 'unicode': 0.24; 'initial': 0.24; 'mon,': 0.24; 'paul': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'tim': 0.29; 'wonder': 0.29; "doesn't": 0.30; 'characters': 0.30; 'mode': 0.30; 'needed.': 0.30; 'specified': 0.30; 'code': 0.31; 'getting': 0.31; '>>>>': 0.31; 'coded': 0.31; 'dropped': 0.31; 'writes:': 0.31; 'file': 0.32; 'probably': 0.32; 'run': 0.32; 'text': 0.33; 'linux': 0.33; 'url:python': 0.33; 'checking': 0.33; 'actual': 0.34; 'comment': 0.34; "i'd": 0.34; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'subject:?': 0.36; 'should': 0.36; 'searching': 0.37; 'throughout': 0.37; 'too': 0.37; 'skip:o 20': 0.38; 'thank': 0.38; 'todo': 0.38; 'to:addr :python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'march': 0.61; 'success': 0.61; "you're": 0.61; 'skip:n 10': 0.64; '30,': 0.65; 'charset:windows-1252': 0.65; 'bottom': 0.67; 'mar': 0.68; 'anything.': 0.68; 'received:74.208': 0.68; 'url:me': 0.69; 'day': 0.76; 'subject:this': 0.83; '2015': 0.84; 'comparable': 0.84; 'safer': 0.84; 'size?': 0.84; 'start.': 0.84; 'url:master': 0.84; 'waking': 0.84; 'apparent': 0.91; 'subject:Best': 0.91 Date: Mon, 30 Mar 2015 14:35:27 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Strategy/ Advice for How to Best Attack this Problem? References: <87a8yvs34u.fsf@jester.gateway.pace.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:FYY64EBQa/+JBitekezqyMQ/7/LZP6qVvrzkoBjJX+MTrzyya4X ILYvqi1qxIh+izwOK4Tziaf1rml4Oa5+WQoKDnjEH2Lw/kf+0Gyba0dA6WEpnKnjkOMUwlh R5oZXmdN9K/1OFl1pjGh+uGoXNmGdcnHYje3WF4O/i5FqR7ejuhO/dTsBJpHMCskfufU/LS QtdYEipH8rw9iBl0B4cww== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 65 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427740538 news.xs4all.nl 2826 [2001:888:2000:d::a6]:53343 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88339 On 03/30/2015 12:45 PM, Saran A wrote: > On Sunday, March 29, 2015 at 10:04:45 PM UTC-4, Chris Angelico wrote: >> On Mon, Mar 30, 2015 at 12:08 PM, Paul Rubin wrote: >>> Saran Ahluwalia writes: >>>> cross-platform... >>>> * Monitors a folder for files that are dropped throughout the day >>> >>> I don't see a cross-platform way to do that other than by waking up and >>> scanning the folder every so often (once a minute, say). The Linux way >>> is with inotify and there's a Python module for it (search terms: python >>> inotify). There might be comparable but non-identical interfaces for >>> other platforms. >> >> All too often, "cross-platform" means probing for one option, then >> another, then another, and using whichever one you can. On Windows, >> there's FindFirstChangeNotification and ReadDirectoryChanges, which >> Tim Golden wrote about, and which I coded up into a teleporter for >> getting files out of a VM automatically: >> >> http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html >> https://github.com/Rosuav/shed/blob/master/senddir.py >> >> ChrisA > > @Dave, Chris, Paul and Dennis: Thank you for resources and the notes regarding what I should keep in mind. I have an initial commit: https://github.com/ahlusar1989/IntroToPython/blob/master/Project1WG_with_assumptions_and_comments.py > > I welcome your thoughts on this > It's missing a number of your requirements. But it's a start. If it were my file, I'd have a TODO comment at the bottom stating known changes that are needed. In it, I'd mention: 1) your present code is assuming all filenames come directly from the commandline. No searching of a directory. 2) your present code does not move any files to success or failure directories 3) your present code doesn't calculate or write to a text file any statistics. 4) your present code runs once through the names, and terminates. It doesn't "monitor" anything. 5) your present code doesn't check for zero-length files I'd also wonder why you bother checking whether the os.path.getsize(file) function returns the same value as the os.SEEK_END and ftell() code does. Is it that you don't trust the library? Or that you have to run on Windows, where the line-ending logic can change the apparent file size? I notice you're not specifying a file mode on the open. So in Python 3, your sizes are going to be specified in unicode characters after decoding. Is that what the spec says? It's probably safer to explicitly specify the mode (and the file encoding if you're in text). I see you call strip() before comparing the length. Could there ever be leading or trailing whitespace that's significant? Is that the actual specification of line size? -- DaveA