Merge "Improving Gerrit + commit-log automation."
diff --git a/jeepyb/cmd/create_cgitrepos.py b/jeepyb/cmd/create_cgitrepos.py
index d8da88b..8bd12e6 100644
--- a/jeepyb/cmd/create_cgitrepos.py
+++ b/jeepyb/cmd/create_cgitrepos.py
@@ -16,6 +16,9 @@
 # create_cgitrepos.py reads the project config file called projects.yaml
 # and generates a cgitrepos configuration file which is then copied to
 # the cgit server.
+#
+# It also creates the necessary top-level directories for each project
+# organization (openstack, stackforge, etc)
 
 import os
 import yaml
@@ -39,6 +42,9 @@
         assert name not in names
         names.add(name)
         gitorgs.setdefault(org, []).append((name, description))
+    for org in gitorgs:
+        if not os.path.isdir('%s/%s' % (REPO_PATH, org)):
+            os.makedirs('%s/%s' % (REPO_PATH, org))
     with open(CGIT_REPOS, 'w') as cgit_file:
         cgit_file.write('# Autogenerated by create_cgitrepos.py\n')
         for org in sorted(gitorgs):
diff --git a/jeepyb/cmd/run_mirror.py b/jeepyb/cmd/run_mirror.py
index 8e84479..70a89c9 100644
--- a/jeepyb/cmd/run_mirror.py
+++ b/jeepyb/cmd/run_mirror.py
@@ -50,6 +50,7 @@
 # makes it suitable for running in a cron job with only stdout
 # redirected to a log, and also avoids one broken project preventing
 # caching of requirements for others.
+from __future__ import print_function
 
 import argparse
 import datetime
@@ -122,7 +123,7 @@
 
     def debug(self, msg):
         if self.args.debug:
-            print msg
+            print(msg)
 
     def process_http_requirements(self, reqlist, pip_cache_dir, pip):
         new_reqs = []
@@ -157,9 +158,11 @@
 
     def build_mirror(self, mirror):
         print("Building mirror: %s" % mirror['name'])
-        pip_format = ("%s install -M -U %s --exists-action=w "
+        pip_format = ("%s install -U %s --exists-action=w "
                       "--download-cache=%s --build %s -r %s")
         venv_format = ("virtualenv --clear --extra-search-dir=%s %s")
+        upgrade_format = ("%s install -U --exists-action=w "
+                          "--download-cache=%s --build %s %s")
 
         workdir = tempfile.mkdtemp()
         reqs = os.path.join(workdir, "reqs")
@@ -214,6 +217,12 @@
                 if reqlist:
                     out = self.run_command(venv_format %
                                            (pip_cache_dir, venv))
+                    out = self.run_command(upgrade_format %
+                                           (pip, pip_cache_dir,
+                                            build, "setuptools"))
+                    out = self.run_command(upgrade_format %
+                                           (pip, pip_cache_dir,
+                                            build, "pip"))
                     if os.path.exists(build):
                         shutil.rmtree(build)
                     new_reqs = self.process_http_requirements(reqlist,