[Debtorrent-commits] r63 - in /debtorrent/trunk: btdownloadheadless.py btlaunchmany.py bttrack.py
camrdale-guest at users.alioth.debian.org
camrdale-guest at users.alioth.debian.org
Sat May 26 21:04:19 UTC 2007
Author: camrdale-guest
Date: Sat May 26 21:04:19 2007
New Revision: 63
URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=63
Log:
Improve profiling.
Modified:
debtorrent/trunk/btdownloadheadless.py
debtorrent/trunk/btlaunchmany.py
debtorrent/trunk/bttrack.py
Modified: debtorrent/trunk/btdownloadheadless.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/btdownloadheadless.py?rev=63&op=diff
==============================================================================
--- debtorrent/trunk/btdownloadheadless.py (original)
+++ debtorrent/trunk/btdownloadheadless.py Sat May 26 21:04:19 2007
@@ -348,11 +348,8 @@
import profile, pstats
p = profile.Profile()
p.runcall(run, argv[1:])
- log = open('profile_data.'+strftime('%y%m%d%H%M%S')+'.txt','a')
- normalstdout = sys.stdout
- sys.stdout = log
+ p.dump_stats('btdownloadheadless.pstat')
# pstats.Stats(p).strip_dirs().sort_stats('cumulative').print_stats()
pstats.Stats(p).strip_dirs().sort_stats('time').print_stats()
- sys.stdout = normalstdout
else:
run(argv[1:])
Modified: debtorrent/trunk/btlaunchmany.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/btlaunchmany.py?rev=63&op=diff
==============================================================================
--- debtorrent/trunk/btlaunchmany.py (original)
+++ debtorrent/trunk/btlaunchmany.py Sat May 26 21:04:19 2007
@@ -37,6 +37,8 @@
except:
True = 1
False = 0
+
+PROFILER = True
def hours(n):
"""Formats seconds into a human-readable time.
@@ -122,10 +124,16 @@
self.message('SYSTEM ERROR - EXCEPTION GENERATED')
-if __name__ == '__main__':
- if argv[1:] == ['--version']:
- print version
- exit(0)
+def run(params):
+ """Runs the downloader.
+
+ The main function used to create the displayer and start the download.
+
+ @type params: C{list} of C{strings}
+ @param params: a list of the command-line arguments given to the script
+
+ """
+
defaults.extend( [
( 'parse_dir_interval', 60,
"how often to rescan the torrent directory, in seconds" ),
@@ -148,7 +156,7 @@
print "<directory> - directory to look for .dtorrent files (semi-recursive)"
print get_usage(defaults, 80, configdefaults)
exit(1)
- config, args = parseargs(argv[1:], defaults, 1, 1, configdefaults)
+ config, args = parseargs(params, defaults, 1, 1, configdefaults)
if config['save_options']:
configdir.saveConfig(config)
configdir.deleteOldCacheData(config['expire_cache_data'])
@@ -163,4 +171,19 @@
if Exceptions:
print '\nEXCEPTION:'
print Exceptions[0]
- print 'please report this to '+report_email
+ print 'please report this to '+report_email
+
+if __name__ == '__main__':
+ if argv[1:] == ['--version']:
+ print version
+ exit(0)
+
+ if PROFILER:
+ import profile, pstats
+ p = profile.Profile()
+ p.runcall(run, argv[1:])
+ p.dump_stats('btlaunchmany.pstat')
+# pstats.Stats(p).strip_dirs().sort_stats('cumulative').print_stats()
+ pstats.Stats(p).strip_dirs().sort_stats('time').print_stats()
+ else:
+ run(argv[1:])
Modified: debtorrent/trunk/bttrack.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/bttrack.py?rev=63&op=diff
==============================================================================
--- debtorrent/trunk/bttrack.py (original)
+++ debtorrent/trunk/bttrack.py Sat May 26 21:04:19 2007
@@ -25,15 +25,10 @@
if __name__ == '__main__':
if PROFILE:
import profile, pstats
- from time import strftime
- import sys
p = profile.Profile()
p.runcall(track, argv[1:])
- log = open('profile_data.'+strftime('%y%m%d%H%M%S')+'.txt','a')
- normalstdout = sys.stdout
- sys.stdout = log
+ p.dump_stats('bttrack.pstat')
# pstats.Stats(p).strip_dirs().sort_stats('cumulative').print_stats()
pstats.Stats(p).strip_dirs().sort_stats('time').print_stats()
- sys.stdout = normalstdout
else:
track(argv[1:])
More information about the Debtorrent-commits
mailing list