chiark / gitweb /
Merge branch 'newcomers' into 'master'
authorHans-Christoph Steiner <hans@guardianproject.info>
Sat, 16 Sep 2017 08:07:56 +0000 (08:07 +0000)
committerHans-Christoph Steiner <hans@guardianproject.info>
Sat, 16 Sep 2017 08:07:56 +0000 (08:07 +0000)
allow starting without config.py

See merge request fdroid/fdroidserver!335

1  2 
fdroidserver/common.py

diff --combined fdroidserver/common.py
index 815cf3eb7fd4f04af511fe4ee2ac9648e2eaa090,6e4e5d8dbf543aa29cec8fe5a31cfd8d902f7f01..a39b671a7560685e5c091338f4f288cbe41b0d13
@@@ -49,7 -49,6 +49,7 @@@ from pyasn1.error import PyAsn1Erro
  from distutils.util import strtobool
  
  import fdroidserver.metadata
 +from fdroidserver import _
  from fdroidserver.exception import FDroidException, VCSException, BuildException
  from .asynchronousfilereader import AsynchronousFileReader
  
@@@ -124,9 -123,9 +124,9 @@@ default_config = 
  
  def setup_global_opts(parser):
      parser.add_argument("-v", "--verbose", action="store_true", default=False,
 -                        help="Spew out even more information than normal")
 +                        help=_("Spew out even more information than normal"))
      parser.add_argument("-q", "--quiet", action="store_true", default=False,
 -                        help="Restrict output to warnings and errors")
 +                        help=_("Restrict output to warnings and errors"))
  
  
  def fill_config_defaults(thisconfig):
@@@ -239,8 -238,8 +239,8 @@@ def read_config(opts, config_file='conf
          with io.open(config_file, "rb") as f:
              code = compile(f.read(), config_file, 'exec')
              exec(code, None, config)
-     elif len(get_local_metadata_files()) == 0:
-         raise FDroidException("Missing config file - is this a repo directory?")
+     else:
+         logging.debug("No config.py found - using defaults.")
  
      for k in ('mirrors', 'install_list', 'uninstall_list', 'serverwebroot', 'servergitroot'):
          if k in config:
@@@ -1023,9 -1022,9 +1023,9 @@@ def retrieve_string(app_dir, string, xm
              os.path.join(app_dir, 'res'),
              os.path.join(app_dir, 'src', 'main', 'res'),
          ]:
 -            for r, d, f in os.walk(res_dir):
 -                if os.path.basename(r) == 'values':
 -                    xmlfiles += [os.path.join(r, x) for x in f if x.endswith('.xml')]
 +            for root, dirs, files in os.walk(res_dir):
 +                if os.path.basename(root) == 'values':
 +                    xmlfiles += [os.path.join(root, x) for x in files if x.endswith('.xml')]
  
      name = string[len('@string/'):]
  
@@@ -2315,7 -2314,10 +2315,10 @@@ def write_to_config(thisconfig, key, va
          value = thisconfig[origkey] if origkey in thisconfig else thisconfig[key]
      cfg = config_file if config_file else 'config.py'
  
-     # load config file
+     # load config file, create one if it doesn't exist
+     if not os.path.exists(cfg):
+         os.mknod(cfg)
+         logging.info("Creating empty " + cfg)
      with open(cfg, 'r', encoding="utf-8") as f:
          lines = f.readlines()