View Single Post

Thread: audio.Sound Runtime Error in SIS file

#3 Old Re: audio.Sound Runtime Error in SIS file - 2006-03-27, 18:00

Join Date: Aug 2004
Posts: 289
simo.salminen
Offline
Regular Contributor
For standalone script, I recommend making an entry point default.py that does two things: setup logging, and starts the main app. This will speed up finding these kinds of probs. Note that this will start logging IFF debug\ subdir is present. This has added benefit that when you ship your program, and users run into problem, they can create the debug\ dir and you hopefully get the exception that occured.

default.py
Code:
import sys
import os

import logger

debug_path = os.path.join(os.path.dirname(sys.argv[0]), "debug")
if os.path.exists(debug_path):
    my_log = logger.Logger(os.path.join(debug_path, "debug.txt"))
    sys.stderr = sys.stdout = my_log
    print "debug started"

import yourapplication
yourapplication.run()
logger.py
Code:
class Logger:
    def __init__(self, log_name):
        self.logfile = log_name
        
    def write(self, obj):
        log_file = open(self.logfile, 'a')
        log_file.write(obj)
        log_file.close()
        
    def writelines(self, obj):
        self.write(''.join(list))
        
    def flush(self):
        pass
Reply With Quote
 
 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowpostE2ephpE3fpE3d252116E26postcountE3d2X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE44iscussionE45ntryQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE44iscussionE45ntryQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE44iscussionE45ntryQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ