473,799 Members | 3,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extra Newby question - Trying to create md5 File Listing


I've never written a Python program before and I'm trying to read a config
file with file path/names (eg. c:\\python24\\* .dll, ... *.exe) to create an
output file of filename + md5 values. I'm confused. I'm trying to learn
how to use Wing IDE and step through the Stack Data. It seems to be
working but on the
for fn in filelist:
data = file(fn,'rb').r ead()
I get a
IOError: (2, 'No such file or directory', 'c')

Traceback (innermost last):

File "c:\Python examples\md5mak r_test4.py", line 1, in ?
#!/usr/bin/python
File "c:\Python examples\md5mak r_test4.py", line 20, in ?
data = file(fn,'rb').r ead()
Code:
#!/usr/bin/python
# Filename: md5makr_test4.p y

import sys, os, os.path, glob, md5, ConfigParser

config = ConfigParser.Co nfigParser()
config.read('md 5makr.ini')

outputfilname = config.get('gen eral', 'outputfile')
f = file(outputfiln ame,'wt')
fileconfig = config.get('gen eral', 'inputfiles')

fl = file(fileconfig ,'r')
fileData = fl.read()

for f1 in glob.glob(fileD ata):
filelist = f1

for fn in filelist:
data = file(fn,'rb').r ead()
hexstring = md5.md5(data).h exdigest()
f.write(fn + '\t' + hexstring + '/n')

f.close()

Any insight or help would be appreciated.
Sep 27 '06 #1
1 1512
Jim
Thanks Dennis, I'm feeling very stupid. You're right about the config
file containing drive/path/filenames (eg. c:\python24\*.e xe or
whatever). I want to output a text file that contains records like
c:\python24\pyt honw.exe[tab]md5 value, ... next file record. The
following snippet works but I don't know how to loop through using the
config value to get e glob for each file. I'll keep working at it.

filelist = glob.glob('c:\\ python24\\*.exe ')

# print 'filelist is', filelist

for fn in filelist:
data = file(fn,'rb').r ead()
hexstring = md5.md5(data).h exdigest()
f.write(fn + '\t' + hexstring + '\n')

f.close()

Thanks.

Sep 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2386
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File (Employees), and the other is an Address File (Addresses) linked by SSN. I've set Addresses as a Lookup Table - If the user starts typing in the SSN it should pull up the Employees records. I'm getting stuck in the Data Entry form. When I type in...
19
6274
by: MLH | last post by:
I call the following Sub and Function in frmLaunch's OnOpen event code. I keep getting Property Not Found error for the AllowBypassKey setting. Failure point is line #30 in the Function (not the Sub). Ideas? Sub SetStartupProperties() On Error GoTo SetStartupProperties_Err 10 ChangeProperty "StartupForm", dbText, "frmLaunch" ' Form you want to open at startup 20 ChangeProperty "StartupShowDBWindow", dbBoolean, False ...
11
2454
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't find a file when extra path information is added. Is there a switch in ASP or something I can change that'll get it to work? Thanks!
4
3689
by: Jim | last post by:
Hi There, I'm trying to read a file character by character. When I write the file out, there is one extra character which shows on the screen as a solid circle with a small question mark in the middle. Here is what I have: infile = fopen("encrypted.txt", "r"); outfile = fopen("plain.txt", "w");
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.