minimal steps to have cw running on windows 3.5
authorAurélien Campéas
Mon, 07 Sep 2009 12:22:14 +0200
branch3.5
changeset 3115 29262ba01464
parent 3103 1d09765ee720
child 3116 8bf500eb01d6
minimal steps to have cw running on windows * use a portable temporary directory path * conditionalize some imports (for uncrucial functionality) * do not try to install plpythonu (some DLL problem)
cwconfig.py
cwctl.py
etwist/server.py
server/serverctl.py
toolsutils.py
--- a/cwconfig.py	Thu Sep 03 14:08:17 2009 +0200
+++ b/cwconfig.py	Mon Sep 07 12:22:14 2009 +0200
@@ -20,6 +20,7 @@
 from smtplib import SMTP
 from threading import Lock
 from os.path import exists, join, expanduser, abspath, normpath, basename, isdir
+import tempfile
 
 from logilab.common.decorators import cached
 from logilab.common.deprecation import deprecated
@@ -526,13 +527,13 @@
     if CubicWebNoAppConfiguration.mode == 'test':
         root = os.environ['APYCOT_ROOT']
         REGISTRY_DIR = '%s/etc/cubicweb.d/' % root
-        RUNTIME_DIR = '/tmp/'
+        RUNTIME_DIR = tempfile.gettempdir()
         MIGRATION_DIR = '%s/local/share/cubicweb/migration/' % root
         if not exists(REGISTRY_DIR):
             os.makedirs(REGISTRY_DIR)
     elif CubicWebNoAppConfiguration.mode == 'dev':
         REGISTRY_DIR = expanduser('~/etc/cubicweb.d/')
-        RUNTIME_DIR = '/tmp/'
+        RUNTIME_DIR = tempfile.gettempdir()
         MIGRATION_DIR = join(CW_SOFTWARE_ROOT, 'misc', 'migration')
     else: #mode = 'installed'
         REGISTRY_DIR = '/etc/cubicweb.d/'
@@ -651,7 +652,7 @@
     def default_log_file(self):
         """return default path to the log file of the instance'server"""
         if self.mode == 'dev':
-            basepath = '/tmp/%s-%s' % (basename(self.appid), self.name)
+            basepath = join(tempfile.gettempdir(), '%s-%s' % (basename(self.appid), self.name))
             path = basepath + '.log'
             i = 1
             while exists(path) and i < 100: # arbitrary limit to avoid infinite loop
--- a/cwctl.py	Thu Sep 03 14:08:17 2009 +0200
+++ b/cwctl.py	Mon Sep 07 12:22:14 2009 +0200
@@ -5,7 +5,13 @@
 %s"""
 
 import sys
-from os import remove, listdir, system, kill, getpgid, pathsep
+from os import remove, listdir, system, pathsep
+try:
+    from os import kill, getpgid
+except ImportError:
+    def kill(*args): pass
+    def getpgid(): pass
+
 from os.path import exists, join, isfile, isdir
 
 from logilab.common.clcommands import register_commands, pop_arg
--- a/etwist/server.py	Thu Sep 03 14:08:17 2009 +0200
+++ b/etwist/server.py	Mon Sep 07 12:22:14 2009 +0200
@@ -16,7 +16,10 @@
 import hotshot
 
 from twisted.application import service, strports
-from twisted.scripts._twistd_unix import daemonize
+try:
+    from twisted.scripts._twistd_unix import daemonize
+except ImportError:
+    pass
 from twisted.internet import reactor, task, threads
 from twisted.internet.defer import maybeDeferred
 from twisted.web2 import channel, http, server, iweb
--- a/server/serverctl.py	Thu Sep 03 14:08:17 2009 +0200
+++ b/server/serverctl.py	Mon Sep 07 12:22:14 2009 +0200
@@ -312,7 +312,8 @@
         # postgres specific stuff
         if driver == 'postgres':
             # install plpythonu/plpgsql language if not installed by the cube
-            for extlang in ('plpythonu', 'plpgsql'):
+            langs = ('plpgsql',) if sys.platform == 'win32' else ('plpythonu', 'plpgsql') 
+            for extlang in langs:
                 helper.create_language(cursor, extlang)
         cursor.close()
         cnx.commit()
@@ -676,7 +677,7 @@
         import tempfile
         srcappid = pop_arg(args, 1, msg='No source instance specified !')
         destappid = pop_arg(args, msg='No destination instance specified !')
-        output = tempfile.mkstemp(dir='/tmp/')[1]
+        output = tempfile.mkstemp()[1]
         if ':' in srcappid:
             host, srcappid = srcappid.split(':')
             _remote_dump(host, srcappid, output, self.config.sudo)
--- a/toolsutils.py	Thu Sep 03 14:08:17 2009 +0200
+++ b/toolsutils.py	Mon Sep 07 12:22:14 2009 +0200
@@ -10,9 +10,15 @@
 # XXX move most of this in logilab.common (shellutils ?)
 
 import os, sys
-from os import listdir, makedirs, symlink, environ, chmod, walk, remove
+from os import listdir, makedirs, environ, chmod, walk, remove
 from os.path import exists, join, abspath, normpath
 
+try:
+    from os import symlink
+except ImportError:
+    def symlink(*args):
+        raise NotImplementedError
+
 from logilab.common.clcommands import Command as BaseCommand, \
      main_run as base_main_run
 from logilab.common.compat import any