Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Python
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Python section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old May 7th, 2013, 05:46 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: May 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy create-reuse-modify

the code given in chapter 2 of ceate-modify-reuse in python book to compare snapshots is not working.....
its not comparing the snapshots and giving exception message can anyone help me?

the complete code is available in code resources section of this site

parameters are passed in snap1 and snap2
its giving exception mssg "Problems encountered accessing snapshot files!"
here is the code:
def compareSnapshots(snapfile1, snapfile2):

pkl_file = open(snapfile1, 'rb')
dirs1 = pickle.load(pkl_file)
files1 = pickle.load(pkl_file)

pk2_file = open(snapfile2, 'rb')
dirs2 = pickle.load(pk2_file)
files2 = pickle.load(pk2_file)
print "Problems encountered accessing snapshot files!"
raw_input("\n\nPress [Enter] to continue...")

result_dirs = list(difflib.unified_diff(dirs1, dirs2))
result_files = list(difflib.unified_diff(files1, files2))

added_dirs = []
removed_dirs = []
added_files = []
removed_files = []

for result in result_files:
if result.endswith("\n") == -1:
if result.startswith('+'):
resultadd = result.strip('+')
elif result.startswith('-'):
resultsubtract = result.strip('-')

for result in result_dirs:
if result.endswith("\n") == -1:
if result.startswith('+'):
resultadd = result.strip('+')
elif result.startswith('-'):
resultsubtract = result.strip('-')

print "\n\nAdded Directories:\n"
print "\n\nAdded Files:\n"
print "\n\nRemoved Directories:\n"
print "\n\nRemoved Files:\n"
raw_input("\n\nPress [Enter] to continue...")

Reply With Quote
  #2 (permalink)  
Old September 23rd, 2013, 03:49 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts


I've just bumped into the same issue. Did you manage to debug it?

Actually, I don't get the exception, but the result is always empty as if the snapshot were identical, and I'm sure I added some directories and files and removed other before taking the second snapshot.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adobe AIR: Create-Modify-Reuse (978-0-470-18207-9) jaswanttak BOOK: Adobe AIR: Create - Modify - Reuse ISBN: 978-0-470-18207-9 3 April 16th, 2009 11:48 AM
modify create appointment wizard jeanhl BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 March 24th, 2008 03:37 AM
XSL: template reuse ramesh.kumarm XSLT 16 December 1st, 2006 05:27 AM
How to reuse my application ankur_bhargava2000 VB How-To 1 October 17th, 2005 12:49 PM
Reuse in ASP. rupen Classic ASP Basics 3 June 29th, 2005 10:12 AM

All times are GMT -4. The time now is 12:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.