Commits

Donald Stufft  committed cd753af

Make the config.ini file relative

  • Participants
  • Parent commits ecfc1b8

Comments (0)

Files changed (7)

 import zipfile, gzip, tarfile
 #sys.path.append('/usr/local/pypi/lib')
 
+prefix = os.path.dirname(__file__)
+sys.path.insert(0, prefix)
+
+CONFIG_FILE = os.environ.get("PYPI_CONFIG", os.path.join(prefix, 'config.ini'))
+
 import store, config
 
 def set_password(store, name, pw):
         print 'WOULD HAVE removed %d packages' % len(hits)
 
 if __name__ == '__main__':
-    config = config.Config('/data/pypi/config.ini')
+    config = config.Config(CONFIG_FILE)
     st = store.Store(config)
     st.open()
     command = sys.argv[1]
 #!/usr/bin/python
-# 
+#
 # $Id$
 
 import sys, os, cgi, StringIO, traceback
     print 'The Cheese Shop server is down for a short time for maintenance.'
     print 'Please try to connect later.'
     sys.exit(0)
-    
+
 #
 # Provide interface to CGI HTTP response handling
 #
     sys.path.insert(0, '/data/pypi/src/pypi')
     from webui import WebUI
     import config
-    cfg = config.Config('/data/pypi/config.ini')
+    cfg = config.Config(os.environ.get("PYPI_COFNIG", "config.ini"))
     request = RequestWrapper(cfg, sys.stdin, sys.stdout)
     handler = WebUI(request, os.environ)
     handler.run()
 #!/usr/bin/python
-# 
+#
 # $Id$
 
+import os.path
+import sys
+
+prefix = os.path.dirname(__file__)
+sys.path.insert(0, prefix)
+
 from mod_python import apache
 import sys, os, cgi, StringIO, traceback
 from BaseHTTPServer import BaseHTTPRequestHandler, DEFAULT_ERROR_MESSAGE
 from webui import WebUI
 import config
 
+CONFIG_FILE = os.environ.get("PYPI_CONFIG", os.path.join(prefix, 'config.ini'))
+
 class RequestWrapper:
     '''Used to make the CGI server look like a BaseHTTPRequestHandler
     '''
 
 def handle(req):
     req.content_type = req.headers_out['Content-Type'] = 'text/html'
-    cfg = config.Config('/data/pypi/config.ini')
+    cfg = config.Config(os.environ.get("PYPI_COFNIG", CONFIG_FILE))
     request = RequestWrapper(cfg, req)
     pseudoenv = {}
     pseudoenv['CONTENT_TYPE'] = req.headers_in.get('content-type', '')

File sshkeys_update.py

 #!/usr/bin/python
+import os, sys
+
+prefix = os.path.dirname(__file__)
+sys.path.insert(0, prefix)
+
+CONFIG_FILE = os.environ.get("PYPI_CONFIG", os.path.join(prefix, 'config.ini'))
+
 import config, store, os
 standalone_py = os.path.join(os.path.dirname(__file__), 'standalone.py')
-c = config.Config("/data/pypi/config.ini")
+c = config.Config(CONFIG_FILE)
 s = store.Store(c)
 cursor = s.get_cursor()
 cursor.execute("lock table sshkeys in exclusive mode") # to prevent simultaneous updates

File standalone.py

 #!/usr/bin/python
 import config, webui, BaseHTTPServer, urllib, sys, getopt, os
 
+prefix = os.path.dirname(__file__)
+sys.path.insert(0, prefix)
+
+CONFIG_FILE = os.environ.get("PYPI_CONFIG", os.path.join(prefix, 'config.ini'))
+
+
 class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
-    config = config.Config(os.path.dirname(__file__)+"/config.ini")
+    config = config.Config(CONFIG_FILE)
     ssh_user = None
 
     def set_content_type(self, content_type):
         if i >= 0:
             rest, query = rest[:i], rest[i+1:]
         else:
-            query = ''            
+            query = ''
 
         env = {}
         #env['SERVER_SOFTWARE'] = self.version_string()

File tools/integrate-redis-stats.py

             )
 
 # Update the database
-c = config.Config("/data/pypi/config.ini")
+c = config.Config(os.path.join(root, "config.ini"))
 store = store.Store(c)
 cursor = store.get_cursor()
 cursor.executemany(

File tools/worker.py

 
 import config
 
-conf = config.Config(os.environ.get("PYPI_CONFIG", "/data/pypi/config.ini"))
+conf = config.Config(os.environ.get("PYPI_CONFIG", os.path.join(root, "config.ini")))
 redis_conn = redis.Redis.from_url(conf.redis_url)
 
 # Create our queues