apenwarr-redo/redo/title.py
Avery Pennarun 0b648521fd Move setproctitle() stuff into title.py.
This removes another instance of magical code running at module import
time.  And the process title wasn't really part of the state database
anyway.

Unfortunately this uncovered a bug: the recent change to use
'python -S' makes it not find the setproctitle module if installed.

My goodness, I hate the horrible python easy_install module gunk that
makes startup linearly slower the more modules you have installed,
whether you import them or not, if you don't use -S.  But oh well,
we're stuck with it for now.
2018-12-05 02:28:34 -05:00

17 lines
502 B
Python

import os, sys
# FIXME: setproctitle module is only usable if *not* using python -S,
# and without -S, python startup time is annoyingly longer
try:
from setproctitle import setproctitle
except ImportError:
def setproctitle(name):
pass
def auto():
"""Automatically clean up the title as seen by 'ps', based on argv."""
exe = sys.argv[0]
exename, ext = os.path.splitext(os.path.basename(sys.argv[0]))
title = ' '.join([exename] + sys.argv[1:])
setproctitle(title)