Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 2nd, 2005, 6:51 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Smile Keeping Your Publicly Released Programs...

Keeping Your Publicly Released Programs Automatically Updated

Program: This will be run with Python once an update has or hasn't occured.

Web Directory: The Update Instructions and Contents are here.

Version Data: Contains a number with the current version number, in the same folder as the program and this file.

Update Instuctions: Contains a number which if higer then the version number, will process all the listed files underneath to current working directory.

Version Data:
Update Instructions:
2
example_9.py
Battle%20System.py
Output:
Will ask if the user wants an update.
Will copy all the files listed to the current working directory.
Will execute main.py.
It's good for situations where you've released your program to the public, but notice a bug you want to fix. If this is the program they run to execute the program, it will check if an update is needed, and then update the files however you tell it to.

I think it's a good idea at least.
Sane is online now   Reply With Quote
Old Aug 4th, 2005, 12:04 PM   #2
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Yeh, nice script. Updates are pretty sweet.
Bear in mind using an except statement to except any error is really bad practice. Only except the errors you know that arise, or at least put in a print statement that will print the kind of exception that you received, the errno, and the traceback.
Cerulean is offline   Reply With Quote
Old Aug 4th, 2005, 7:12 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
No the except is there in case they are not connected to the internet, or there is no update accessable at the given time. In which case it skips right to your program without worrying about an update.
Sane is online now   Reply With Quote
Old Aug 5th, 2005, 7:12 AM   #4
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Then you should except whatever error is thrown in the case of you not being connected to the internet or there being no update accessible at the given time.
Cerulean is offline   Reply With Quote
Old Aug 5th, 2005, 9:28 AM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
I did.
Sane is online now   Reply With Quote
Old Aug 6th, 2005, 8:19 AM   #6
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
No, you're catching every exception that may get thrown (KeyboardError, MemoryError, IOError, whatever).
How can I explain it... it's kind of like you doing:
rm *
when you only want to do
rm *.txt *.rtf
Cerulean is offline   Reply With Quote
Old Aug 6th, 2005, 1:47 PM   #7
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Yes, I do indeed want to catch all those exceptions and go straight to the program.

Basically I want every error caught and excepted to the main program. Everything except for the condition that an update may be there with a higher version number.
Sane is online now   Reply With Quote
Old Aug 6th, 2005, 3:02 PM   #8
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
Everything except for the condition that an update may be there with a higher version number.
And what happens when there is an update available with a higher version number, but some other bug that you missed the first time round stops the update from happening and you do not realise, because you've told the interpreter "Hey, I don't care what error happens, however critical it is, just forget it"? Say, for example, the update instruction filename changes. You should cater for each individual error that might occur to provide the most graceful method for handling it, not just a lazy all-in-one solution that isn't even a solution.

I'm also a little confused why you have this:
    for a in range(len(x)):
        try:x[a]=x[a].replace('\r','')
        except:pass
        
        try:x[a]=x[a].replace('\n','')
        except:pass
Why the excepts? x should always be a list of strings (or an empty list), and you're within the list's bounds at all times... so what errors are you excepting?
Cerulean is offline   Reply With Quote
Old Aug 6th, 2005, 3:08 PM   #9
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
In case there is no '\r' or '\n' ...
Sane is online now   Reply With Quote
Old Aug 6th, 2005, 3:57 PM   #10
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
No exceptions are raised by replace. There'll just be no replacements.
Cerulean is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC