Back to index

apport  2.3
Public Member Functions
setup.install_fix_hashbangs Class Reference

List of all members.

Public Member Functions

def run

Detailed Description

Fix hashbang lines in scripts in data dir.

Definition at line 55 of file setup.py.


Member Function Documentation

Definition at line 58 of file setup.py.

00058 
00059     def run(self):
00060         DistUtilsExtra.auto.install_auto.run(self)
00061         new_hashbang = '#!%s\n' % sys.executable.rsplit('.', 1)[0]
00062         for (path, _, files) in os.walk(os.path.join(self.install_data, 'share', 'apport')):
00063             for fname in files:
00064                 f = os.path.join(path, fname)
00065                 with open(f) as fd:
00066                     try:
00067                         lines = fd.readlines()
00068                     except UnicodeDecodeError:
00069                         # ignore data files like spinner.gif
00070                         continue
00071                 if lines[0].startswith('#!') and 'python' in lines[0]:
00072                     distutils.log.info('Updating hashbang of %s', f)
00073                     lines[0] = new_hashbang
00074                     with open(f, 'w') as fd:
00075                         for l in lines:
00076                             fd.write(l)
00077 
00078 #
00079 # main
00080 #
00081 
# try to auto-setup packaging_impl

The documentation for this class was generated from the following file: