[CalendarServer-changes] [1094] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 24 10:14:00 PST 2007
Revision: 1094
http://trac.macosforge.org/projects/calendarserver/changeset/1094
Author: dreid at apple.com
Date: 2007-01-24 10:13:59 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
Rewrite all scripts, and support rewriting python an sh scripts. Update caladmin to get the PYTHONPATH from this rewriting.
Modified Paths:
--------------
CalendarServer/trunk/bin/caladmin
CalendarServer/trunk/setup.py
Modified: CalendarServer/trunk/bin/caladmin
===================================================================
--- CalendarServer/trunk/bin/caladmin 2007-01-24 02:57:54 UTC (rev 1093)
+++ CalendarServer/trunk/bin/caladmin 2007-01-24 18:13:59 UTC (rev 1094)
@@ -19,6 +19,11 @@
import sys, os
+#PYTHONPATH
+
if __name__ == '__main__':
+ if PYTHONPATH in globals():
+ sys.path.insert(0, PYTHONPATH)
+
from twistedcaldav.admin.script import run
run()
Modified: CalendarServer/trunk/setup.py
===================================================================
--- CalendarServer/trunk/setup.py 2007-01-24 02:57:54 UTC (rev 1093)
+++ CalendarServer/trunk/setup.py 2007-01-24 18:13:59 UTC (rev 1094)
@@ -100,23 +100,49 @@
root = dist.command_obj['install'].root
base = dist.command_obj['install'].install_base
- caldavdPath = os.path.join(install_scripts, 'caldavd')
-
if root:
install_lib = install_lib[len(root):]
- print "rewriting %s" % (caldavdPath,)
+ for script in dist.scripts:
+ scriptPath = os.path.join(install_scripts, os.path.basename(script))
- caldavd = []
- for line in file(caldavdPath, 'r'):
- line = line.rstrip('\n')
- if line == '#PYTHONPATH':
- caldavd.append('PYTHONPATH="%s:$PYTHONPATH"' % (install_lib,))
- elif line == '#PATH':
- caldavd.append('PATH="%s:$PATH"' % (os.path.join(base, 'bin'),))
- else:
- caldavd.append(line)
+ print "rewriting %s" % (scriptPath,)
- newCaldavd = open(caldavdPath, 'w')
- newCaldavd.write('\n'.join(caldavd))
- newCaldavd.close()
+ script = []
+
+ fileType = None
+
+ for line in file(scriptPath, 'r'):
+ if not fileType:
+ if line.startswith('#!'):
+ if 'python' in line.lower():
+ fileType = 'python'
+ elif 'sh' in line.lower():
+ fileType = 'sh'
+
+ line = line.rstrip('\n')
+ if fileType == 'sh':
+ if line == '#PYTHONPATH':
+ script.append(
+ 'PYTHONPATH="%s:$PYTHONPATH"' % (install_lib,))
+ elif line == '#PATH':
+ script.append(
+ 'PATH="%s:$PATH"' % (os.path.join(base, 'bin'),))
+ else:
+ script.append(line)
+
+ elif fileType == 'python':
+ if line == '#PYTHONPATH':
+ script.append('PYTHONPATH="%s"' % (install_lib,))
+ elif line == '#PATH':
+ script.append(
+ 'PATH="%s"' % (os.path.join(base, 'bin'),))
+ else:
+ script.append(line)
+
+ else:
+ script.append(line)
+
+ newScript = open(scriptPath, 'w')
+ newScript.write('\n'.join(script))
+ newScript.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070124/8695e7a3/attachment.html
More information about the calendarserver-changes
mailing list