Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Python script not processing files

09 Dec 2014   #21
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
The above braces (dictionary data type) and brackets (a list data type) are all, as you can see, empty. It seems the genorate report function only acts upon the data that is supposed to be within these braces. But what stumps me is that there is absolutely nothing in these braces and there never will be. Thus the generateReport function always returns an empty string no matter what file the script reads!
It looks like the assignments are just placeholders to be filled in later. IOW equivalent to bool myfunc { return true } in C++


My System SpecsSystem Spec
.
09 Dec 2014   #22
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by MilesAhead
It looks like the assignments are just placeholders to be filled in later.
That's what one would think at initial glance and is what should happen. But by the looks of things they never do get 'filled' in.
My System SpecsSystem Spec
09 Dec 2014   #23
Docfxit

Win 7 Ultimate x32, x64, Win 7 Pro x32, x64 Win 7 Home x64, XP Pro sp3
 
 

I have been doing some research to try to figure this out. I have found:
According to this link:
https://docs.python.org/2/library/string.html
Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output.

So it appears to me the code:
Code:
Lines 831 - 837 read: 

Code:
---------
        stats = {}
        spammers = []
        unknowns = {}
        blacklists = {}
        spamtraps = {}
        contentRejections = {}
        relayRejections = {}
Will be replaced with text. That will be where the problem is. It's not being replaced.

I really don't know enough about reading Python code but does it look like the first section called "Stats" is filled in at:
Code:
Line starting at 490

    def statistics(self, stats) :
        """Add statistics for this transaction to the given stats"""

        if self.messageSent :
            stats["SMTP"] = stats.get("SMTP", 0) + 1
            if self.messageSent :
                stats["SMTP-Bytes"] = stats.get("SMTP-Bytes", 0) + self.bytesSent
            stats["OutRecip"] = stats.get("OutRecip", 0) + len(self.recipients)

        return stats
If that's true does the script go to that code?

Thanks,

Docfxit
My System SpecsSystem Spec
.

10 Dec 2014   #24
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Lines 831 to 837 are not examples of string formatting. The braces here detonate Python dictionaries whereas the pair brackets are a Python list. While some string formatting practises (i.e. the format method of strings) use braces, the braces mean something very different in this context.

Quote   Quote: Originally Posted by Docfxit View Post
If that's true does the script go to that code?
As it appears, this function never even gets called.


I'd advise you contact the developer of this script for help or get advice from a proper Python scripting forum.
My System SpecsSystem Spec
10 Dec 2014   #25
Docfxit

Win 7 Ultimate x32, x64, Win 7 Pro x32, x64 Win 7 Home x64, XP Pro sp3
 
 

Do you know of any proper Python scripting forums?

Thank you very much for your time looking into this.

Docfxit
My System SpecsSystem Spec
10 Dec 2014   #26
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by Docfxit View Post
Do you know of any proper Python scripting forums?

Thank you very much for your time looking into this.

Docfxit
The link I provided is to the Python.org page which has links to forums for Python programming as you might expect. A good free implementation of Python for Windows is available from ActiveState. The Community Eddition is free and comes in either 2.x or 3.x versions.
My System SpecsSystem Spec
10 Dec 2014   #27
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
Quote   Quote: Originally Posted by MilesAhead
It looks like the assignments are just placeholders to be filled in later.
That's what one would think at initial glance and is what should happen. But by the looks of things they never do get 'filled' in.
That's why I called it a placeholder.
My System SpecsSystem Spec
Reply

 Python script not processing files




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
VB script: Rename all files in a folder to a specified prefix
Hi, I'm trying to find help in entering paths and prefix's in my vb script. I am of course a newbie to visual basic and don't know where to enter the path and wording for prefix. Any help would be most appreciated. Rich
General Discussion
Excel 2013 - Processor overheats when processing large files
Hello, I have a very rare issue here. I'm trying to convert a normal xlsx file into a csv file. In the xlsx file there are normal columns and rows, nothing strange, nor formatting or something pretty, only colums and rows with products plain information. I've received these files via...
Microsoft Office
Script help - downloading files from multiple computers
Hi all, So i am new to scripting and I am having issues figuring out where to start. Hope someone can help. I have 20+ computers that I connect to and grab .txt files. I would like to create a bat file that will connect to the computers and download the files to my local. This will save me...
General Discussion
How to script a daily copy of files w/dt being name of archive folder
Hello, I need to figure out a Windows 7 script to copy/archive files which are located in a specific folder. It needs to copy daily to an archive folder, with the script creating the archive folder as MM-DD-YY (being that day's date that is being archived) before it archives the files to that...
General Discussion
A script to automate moving files off C: prior to backup?
I back up my files and system image weekly. I move the recorded TV shows (broadcast TV, nothing illegal) before that from my hard drive onto an external drive. Another drive in the same cabinet does the backup. It saves time and I won't want those files after a disc failure anyway. It would be...
General Discussion
looking for cmd script to unhide files
at one point i had a virus on a thumbdrive, it would hide all the files in it and say it was un usable data, if you said view hidden files, they would all appear. i had figured out a dll to run in cmd that would unhide the files that where not meant to be hidden such as windows .trashes etc. i had...
System Security


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:47.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App