We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Favicon color should be updated
If we are changing the color scheme, the background color of the favicon (small image that appears on a tab) should be updated to match.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lmfdb/utils/config.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # LMFDB - L-function and Modular Forms Database web-site - www.lmfdb.org
3 # Copyright (C) 2010-2012 by the LMFDB authors
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
9 
10 """
11 This file must not depend on other files from this project.
12 It's purpose is to parse a config file (create a default one if none
13 is present) and replace values stored within it with those given
14 via optional command-line arguments.
15 """
16 import argparse
17 import sys
18 import os
19 
20 class Configuration(object):
21 
22     def __init__(self, writeargstofile = False):
23         default_config_file = "config.ini"
24         root_lmfdb_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..','..'))
25         if root_lmfdb_path != os.path.abspath(os.getcwd()):
26             default_config_file = os.path.relpath(os.path.join(root_lmfdb_path, default_config_file),os.getcwd())
27 
28         # 1: parsing command-line arguments
29         parser  =  argparse.ArgumentParser(description = 'LMFDB - The L-functions and modular forms database')
30         parser.add_argument('-c', '--config-file',
31                 dest = "config_file",
32                 metavar = "FILE",
33                 help = 'configuration file [default: %(default)s]',
34                 default = default_config_file)
35 
36         parser.add_argument(
37             '-d', '--debug',
38             action = "store_true",
39             dest = 'core_debug',
40             help = 'enable debug mode')
41 
42         parser.add_argument(
43             '--color',
44             dest = 'core_color',
45             metavar = "COLOR",
46             help = 'color template (see lmfdb/utils/color.py)',
47             default = 0,
48             type = int)
49 
50         parser.add_argument('-p','--port',
51                 dest = 'web_port',
52                 metavar = 'PORT',
53                 help = 'the LMFDB server will be running on PORT [default: %(default)d]',
54                 type = int,
55                 default = 37777)
56         parser.add_argument('-b', '--bind_ip',
57                 dest = 'web_bindip',
58                 metavar ='HOST',
59                 help = 'the LMFDB server will be listening to HOST [default: %(default)s]',
60                 default = '127.0.0.1')
61 
62         logginggroup = parser.add_argument_group('Logging options:')
63         logginggroup.add_argument('--logfile',
64                 help = 'logfile for flask [default: %(default)s]',
65                 dest = 'logging_logfile',
66                 metavar = 'FILE',
67                 default = 'flasklog')
68 
69         logginggroup.add_argument('--logfocus',
70                 help = 'name of a logger to focus on',
71                 default = argparse.SUPPRESS)
72 
73 
74         logginggroup.add_argument(
75             '--slowcutoff',
76             dest = 'logging_slowcutoff',
77             metavar = "SLOWCUTOFF",
78             help = 'threshold to log slow queries [default: %(default)s]',
79             default = 0.1,
80             type = float)
81 
82         logginggroup.add_argument('--slowlogfile',
83                 help = 'logfile for slow queries [default: %(default)s]',
84                 dest = 'logging_slowlogfile',
85                 metavar = 'FILE',
86                 default = 'slow_queries.log')
87 
88 
89         # PostgresSQL options
90         postgresqlgroup = parser.add_argument_group('PostgreSQL options')
91         postgresqlgroup.add_argument('--postgresql-host',
92                 dest = 'postgresql_host',
93                 metavar = 'HOST',
94                 help = 'PostgreSQL server host or socket directory [default: %(default)s]',
95                 default = 'devmirror.lmfdb.xyz')
96         postgresqlgroup.add_argument('--postgresql-port',
97                 dest = 'postgresql_port',
98                 metavar = 'PORT',
99                 type = int,
100                 help = 'PostgreSQL server port [default: %(default)d]',
101                 default = 5432)
102 
103         postgresqlgroup.add_argument('--postgresql-user',
104                 dest = 'postgresql_user',
105                 metavar = 'USER',
106                 help = 'PostgreSQL username [default: %(default)s]',
107                 default = "lmfdb")
108 
109         postgresqlgroup.add_argument('--postgresql-pass',
110                 dest = 'postgresql_password',
111                 metavar = 'PASS',
112                 help = 'PostgreSQL password [default: %(default)s]',
113                 default = "lmfdb")
114 
115         # undocumented options
116         parser.add_argument('--enable-profiler',
117                 dest = 'profiler',
118                 help=argparse.SUPPRESS,
119                 action='store_true',
120                 default=argparse.SUPPRESS)
121 
122         # undocumented flask options
123         parser.add_argument('--enable-reloader',
124                 dest='use_reloader',
125                 help=argparse.SUPPRESS,
126                 action='store_true',
127                 default=argparse.SUPPRESS)
128 
129         parser.add_argument('--disable-reloader',
130                 dest='use_reloader',
131                 help=argparse.SUPPRESS,
132                 action='store_false',
133                 default=argparse.SUPPRESS)
134 
135         parser.add_argument('--enable-debugger',
136                 dest='use_debugger',
137                 help=argparse.SUPPRESS,
138                 action = 'store_true',
139                 default=argparse.SUPPRESS)
140 
141         parser.add_argument('--disable-debugger',
142                 dest='use_debugger',
143                 help=argparse.SUPPRESS,
144                 action='store_false',
145                 default=argparse.SUPPRESS)
146         if os.path.split(sys.argv[0])[-1] == "start-lmfdb.py" or writeargstofile:
147             args = parser.parse_args()
148         else:
149             # only read config file
150             args = parser.parse_args([])
151         args_dict = vars(args)
152         default_arguments_dict = vars(parser.parse_args([]))
153         if writeargstofile:
154             default_arguments_dict = dict(args_dict)
155 
156         del default_arguments_dict['config_file']
157 
158         self.default_args = {}
159         for key, val in default_arguments_dict.iteritems():
160             sec, opt = key.split('_', 1)
161             if sec not in self.default_args:
162                 self.default_args[sec] = {}
163             self.default_args[sec][opt] = str(val)
164 
165 
166 
167         from ConfigParser import ConfigParser
168 
169         # reading the config file, creating it if necessary
170         # 2/1: does config file exist?
171         if not os.path.exists(args.config_file):
172             if not writeargstofile:
173                 print("Config file: %s not found, creating it with the default values" % args.config_file )
174             else:
175                 print("Config file: %s not found, creating it with the passed values" % args.config_file )
176             _cfgp  =  ConfigParser()
177 
178             # create sections
179             _cfgp.add_section('core')
180             _cfgp.add_section('web')
181             _cfgp.add_section('postgresql')
182             _cfgp.add_section('logging')
183 
184 
185             for sec, options in self.default_args.iteritems():
186                 for opt, val in options.iteritems():
187                     _cfgp.set(sec, opt, str(val))
188 
189             with open(args.config_file, 'wb') as configfile:
190                 _cfgp.write(configfile)
191 
192         # 2/2: reading the config file
193         _cfgp  =  ConfigParser()
194         _cfgp.read(args.config_file)
195 
196 
197         # 3: override specific settings
198         def all(sep = '_'):
199             ret  =  {}
200             for s in _cfgp.sections():
201                 for k, v in _cfgp.items(s):
202                     ret['%s%s%s' % (s, sep, k)]  =  v
203             return ret
204 
205         all_set = all()
206 
207         for key, val in default_arguments_dict.iteritems():
208             # if a nondefault value was passed through command line arguments set it
209             # or if a default value was not set in the config file
210             if args_dict[key] != val or key not in all_set:
211                 sec, opt = key.split('_')
212                 _cfgp.set(sec, opt, str(args_dict[key]))
213 
214 
215         # some generic functions
216         def get(section, key):
217             return _cfgp.get(section, key)
218 
219         def getint(section, key):
220             return _cfgp.getint(section, key)
221 
222         def getboolean(section, key):
223             return _cfgp.getboolean(section, key)
224 
225 
226 
227         self.flask_options = {
228                 "port": getint('web', 'port'),
229                 "host": get('web', 'bindip'),
230                 "debug": getboolean('core', 'debug')
231                 }
232         for opt in ['use_debugger', 'use_reloader', 'profiler']:
233             if opt in args_dict:
234                 self.flask_options[opt] = args_dict[opt]
235 
236         self.color = getint('core', 'color')
237 
238         self.postgresql_options = {
239                 "port": getint("postgresql", "port"),
240                 "host": get("postgresql", "host"),
241                 "dbname": "lmfdb"}
242 
243         # optional items
244         for elt in ['user','password']:
245             if _cfgp.has_option("postgresql", elt):
246                 self.postgresql_options[elt] = get("postgresql", elt)
247 
248         self.logging_options = {'logfile': get('logging', 'logfile'), 'slowcutoff':  float(get('logging', 'slowcutoff')), 'slowlogfile': get('logging', 'slowlogfile') }
249         if "logfocus" in args_dict:
250             self.logging_options["logfocus"] = args_dict["logfocus"]
251         if _cfgp.has_option("logging", "editor"):
252             self.logging_options["editor"] = get("logging", "editor")
253 
254     def get_all(self):
255         return { 'flask_options' : self.flask_options, 'postgresql_options' : self.postgresql_options, 'logging_options' : self.logging_options}
256 
257     def get_flask(self):
258         return self.flask_options
259 
260     def get_color(self):
261         return self.color
262 
263     def get_postgresql(self):
264         return self.postgresql_options
265 
266     def get_postgresql_default(self):
267         res = dict(self.default_args["postgresql"])
268         res["port"] = int(res["port"])
269         return res
270 
271     def get_logging(self):
272         return self.logging_options
273 
274 
275 if __name__ == '__main__':
276     Configuration(writeargstofile = True)
277
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lmfdb/utils/config.py b/lmfdb/utils/config.py
--- a/lmfdb/utils/config.py
+++ b/lmfdb/utils/config.py
@@ -44,7 +44,7 @@
             dest = 'core_color',
             metavar = "COLOR",
             help = 'color template (see lmfdb/utils/color.py)',
-            default = 0,
+            default = 19,
             type = int)
 
         parser.add_argument('-p','--port',

{"golden_diff": "diff --git a/lmfdb/utils/config.py b/lmfdb/utils/config.py\n--- a/lmfdb/utils/config.py\n+++ b/lmfdb/utils/config.py\n@@ -44,7 +44,7 @@\n             dest = 'core_color',\n             metavar = \"COLOR\",\n             help = 'color template (see lmfdb/utils/color.py)',\n-            default = 0,\n+            default = 19,\n             type = int)\n \n         parser.add_argument('-p','--port',\n", "issue": "Favicon color should be updated\nIf we are changing the color scheme, the background color of the favicon (small image that appears on a tab) should be updated to match.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# LMFDB - L-function and Modular Forms Database web-site - www.lmfdb.org\n# Copyright (C) 2010-2012 by the LMFDB authors\n#\n# This library is free software; you can redistribute it and/or\n# modify it under the terms of the GNU Library General Public\n# License as published by the Free Software Foundation; either\n# version 2 of the License, or (at your option) any later version.\n\n\"\"\"\nThis file must not depend on other files from this project.\nIt's purpose is to parse a config file (create a default one if none\nis present) and replace values stored within it with those given\nvia optional command-line arguments.\n\"\"\"\nimport argparse\nimport sys\nimport os\n\nclass Configuration(object):\n\n    def __init__(self, writeargstofile = False):\n        default_config_file = \"config.ini\"\n        root_lmfdb_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..','..'))\n        if root_lmfdb_path != os.path.abspath(os.getcwd()):\n            default_config_file = os.path.relpath(os.path.join(root_lmfdb_path, default_config_file),os.getcwd())\n\n        # 1: parsing command-line arguments\n        parser  =  argparse.ArgumentParser(description = 'LMFDB - The L-functions and modular forms database')\n        parser.add_argument('-c', '--config-file',\n                dest = \"config_file\",\n                metavar = \"FILE\",\n                help = 'configuration file [default: %(default)s]',\n                default = default_config_file)\n\n        parser.add_argument(\n            '-d', '--debug',\n            action = \"store_true\",\n            dest = 'core_debug',\n            help = 'enable debug mode')\n\n        parser.add_argument(\n            '--color',\n            dest = 'core_color',\n            metavar = \"COLOR\",\n            help = 'color template (see lmfdb/utils/color.py)',\n            default = 0,\n            type = int)\n\n        parser.add_argument('-p','--port',\n                dest = 'web_port',\n                metavar = 'PORT',\n                help = 'the LMFDB server will be running on PORT [default: %(default)d]',\n                type = int,\n                default = 37777)\n        parser.add_argument('-b', '--bind_ip',\n                dest = 'web_bindip',\n                metavar ='HOST',\n                help = 'the LMFDB server will be listening to HOST [default: %(default)s]',\n                default = '127.0.0.1')\n\n        logginggroup = parser.add_argument_group('Logging options:')\n        logginggroup.add_argument('--logfile',\n                help = 'logfile for flask [default: %(default)s]',\n                dest = 'logging_logfile',\n                metavar = 'FILE',\n                default = 'flasklog')\n\n        logginggroup.add_argument('--logfocus',\n                help = 'name of a logger to focus on',\n                default = argparse.SUPPRESS)\n\n\n        logginggroup.add_argument(\n            '--slowcutoff',\n            dest = 'logging_slowcutoff',\n            metavar = \"SLOWCUTOFF\",\n            help = 'threshold to log slow queries [default: %(default)s]',\n            default = 0.1,\n            type = float)\n\n        logginggroup.add_argument('--slowlogfile',\n                help = 'logfile for slow queries [default: %(default)s]',\n                dest = 'logging_slowlogfile',\n                metavar = 'FILE',\n                default = 'slow_queries.log')\n\n\n        # PostgresSQL options\n        postgresqlgroup = parser.add_argument_group('PostgreSQL options')\n        postgresqlgroup.add_argument('--postgresql-host',\n                dest = 'postgresql_host',\n                metavar = 'HOST',\n                help = 'PostgreSQL server host or socket directory [default: %(default)s]',\n                default = 'devmirror.lmfdb.xyz')\n        postgresqlgroup.add_argument('--postgresql-port',\n                dest = 'postgresql_port',\n                metavar = 'PORT',\n                type = int,\n                help = 'PostgreSQL server port [default: %(default)d]',\n                default = 5432)\n\n        postgresqlgroup.add_argument('--postgresql-user',\n                dest = 'postgresql_user',\n                metavar = 'USER',\n                help = 'PostgreSQL username [default: %(default)s]',\n                default = \"lmfdb\")\n\n        postgresqlgroup.add_argument('--postgresql-pass',\n                dest = 'postgresql_password',\n                metavar = 'PASS',\n                help = 'PostgreSQL password [default: %(default)s]',\n                default = \"lmfdb\")\n\n        # undocumented options\n        parser.add_argument('--enable-profiler',\n                dest = 'profiler',\n                help=argparse.SUPPRESS,\n                action='store_true',\n                default=argparse.SUPPRESS)\n\n        # undocumented flask options\n        parser.add_argument('--enable-reloader',\n                dest='use_reloader',\n                help=argparse.SUPPRESS,\n                action='store_true',\n                default=argparse.SUPPRESS)\n\n        parser.add_argument('--disable-reloader',\n                dest='use_reloader',\n                help=argparse.SUPPRESS,\n                action='store_false',\n                default=argparse.SUPPRESS)\n\n        parser.add_argument('--enable-debugger',\n                dest='use_debugger',\n                help=argparse.SUPPRESS,\n                action = 'store_true',\n                default=argparse.SUPPRESS)\n\n        parser.add_argument('--disable-debugger',\n                dest='use_debugger',\n                help=argparse.SUPPRESS,\n                action='store_false',\n                default=argparse.SUPPRESS)\n        if os.path.split(sys.argv[0])[-1] == \"start-lmfdb.py\" or writeargstofile:\n            args = parser.parse_args()\n        else:\n            # only read config file\n            args = parser.parse_args([])\n        args_dict = vars(args)\n        default_arguments_dict = vars(parser.parse_args([]))\n        if writeargstofile:\n            default_arguments_dict = dict(args_dict)\n\n        del default_arguments_dict['config_file']\n\n        self.default_args = {}\n        for key, val in default_arguments_dict.iteritems():\n            sec, opt = key.split('_', 1)\n            if sec not in self.default_args:\n                self.default_args[sec] = {}\n            self.default_args[sec][opt] = str(val)\n\n\n\n        from ConfigParser import ConfigParser\n\n        # reading the config file, creating it if necessary\n        # 2/1: does config file exist?\n        if not os.path.exists(args.config_file):\n            if not writeargstofile:\n                print(\"Config file: %s not found, creating it with the default values\" % args.config_file )\n            else:\n                print(\"Config file: %s not found, creating it with the passed values\" % args.config_file )\n            _cfgp  =  ConfigParser()\n\n            # create sections\n            _cfgp.add_section('core')\n            _cfgp.add_section('web')\n            _cfgp.add_section('postgresql')\n            _cfgp.add_section('logging')\n\n\n            for sec, options in self.default_args.iteritems():\n                for opt, val in options.iteritems():\n                    _cfgp.set(sec, opt, str(val))\n\n            with open(args.config_file, 'wb') as configfile:\n                _cfgp.write(configfile)\n\n        # 2/2: reading the config file\n        _cfgp  =  ConfigParser()\n        _cfgp.read(args.config_file)\n\n\n        # 3: override specific settings\n        def all(sep = '_'):\n            ret  =  {}\n            for s in _cfgp.sections():\n                for k, v in _cfgp.items(s):\n                    ret['%s%s%s' % (s, sep, k)]  =  v\n            return ret\n\n        all_set = all()\n\n        for key, val in default_arguments_dict.iteritems():\n            # if a nondefault value was passed through command line arguments set it\n            # or if a default value was not set in the config file\n            if args_dict[key] != val or key not in all_set:\n                sec, opt = key.split('_')\n                _cfgp.set(sec, opt, str(args_dict[key]))\n\n\n        # some generic functions\n        def get(section, key):\n            return _cfgp.get(section, key)\n\n        def getint(section, key):\n            return _cfgp.getint(section, key)\n\n        def getboolean(section, key):\n            return _cfgp.getboolean(section, key)\n\n\n\n        self.flask_options = {\n                \"port\": getint('web', 'port'),\n                \"host\": get('web', 'bindip'),\n                \"debug\": getboolean('core', 'debug')\n                }\n        for opt in ['use_debugger', 'use_reloader', 'profiler']:\n            if opt in args_dict:\n                self.flask_options[opt] = args_dict[opt]\n\n        self.color = getint('core', 'color')\n\n        self.postgresql_options = {\n                \"port\": getint(\"postgresql\", \"port\"),\n                \"host\": get(\"postgresql\", \"host\"),\n                \"dbname\": \"lmfdb\"}\n\n        # optional items\n        for elt in ['user','password']:\n            if _cfgp.has_option(\"postgresql\", elt):\n                self.postgresql_options[elt] = get(\"postgresql\", elt)\n\n        self.logging_options = {'logfile': get('logging', 'logfile'), 'slowcutoff':  float(get('logging', 'slowcutoff')), 'slowlogfile': get('logging', 'slowlogfile') }\n        if \"logfocus\" in args_dict:\n            self.logging_options[\"logfocus\"] = args_dict[\"logfocus\"]\n        if _cfgp.has_option(\"logging\", \"editor\"):\n            self.logging_options[\"editor\"] = get(\"logging\", \"editor\")\n\n    def get_all(self):\n        return { 'flask_options' : self.flask_options, 'postgresql_options' : self.postgresql_options, 'logging_options' : self.logging_options}\n\n    def get_flask(self):\n        return self.flask_options\n\n    def get_color(self):\n        return self.color\n\n    def get_postgresql(self):\n        return self.postgresql_options\n\n    def get_postgresql_default(self):\n        res = dict(self.default_args[\"postgresql\"])\n        res[\"port\"] = int(res[\"port\"])\n        return res\n\n    def get_logging(self):\n        return self.logging_options\n\n\nif __name__ == '__main__':\n    Configuration(writeargstofile = True)\n", "path": "lmfdb/utils/config.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# LMFDB - L-function and Modular Forms Database web-site - www.lmfdb.org\n# Copyright (C) 2010-2012 by the LMFDB authors\n#\n# This library is free software; you can redistribute it and/or\n# modify it under the terms of the GNU Library General Public\n# License as published by the Free Software Foundation; either\n# version 2 of the License, or (at your option) any later version.\n\n\"\"\"\nThis file must not depend on other files from this project.\nIt's purpose is to parse a config file (create a default one if none\nis present) and replace values stored within it with those given\nvia optional command-line arguments.\n\"\"\"\nimport argparse\nimport sys\nimport os\n\nclass Configuration(object):\n\n    def __init__(self, writeargstofile = False):\n        default_config_file = \"config.ini\"\n        root_lmfdb_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..','..'))\n        if root_lmfdb_path != os.path.abspath(os.getcwd()):\n            default_config_file = os.path.relpath(os.path.join(root_lmfdb_path, default_config_file),os.getcwd())\n\n        # 1: parsing command-line arguments\n        parser  =  argparse.ArgumentParser(description = 'LMFDB - The L-functions and modular forms database')\n        parser.add_argument('-c', '--config-file',\n                dest = \"config_file\",\n                metavar = \"FILE\",\n                help = 'configuration file [default: %(default)s]',\n                default = default_config_file)\n\n        parser.add_argument(\n            '-d', '--debug',\n            action = \"store_true\",\n            dest = 'core_debug',\n            help = 'enable debug mode')\n\n        parser.add_argument(\n            '--color',\n            dest = 'core_color',\n            metavar = \"COLOR\",\n            help = 'color template (see lmfdb/utils/color.py)',\n            default = 19,\n            type = int)\n\n        parser.add_argument('-p','--port',\n                dest = 'web_port',\n                metavar = 'PORT',\n                help = 'the LMFDB server will be running on PORT [default: %(default)d]',\n                type = int,\n                default = 37777)\n        parser.add_argument('-b', '--bind_ip',\n                dest = 'web_bindip',\n                metavar ='HOST',\n                help = 'the LMFDB server will be listening to HOST [default: %(default)s]',\n                default = '127.0.0.1')\n\n        logginggroup = parser.add_argument_group('Logging options:')\n        logginggroup.add_argument('--logfile',\n                help = 'logfile for flask [default: %(default)s]',\n                dest = 'logging_logfile',\n                metavar = 'FILE',\n                default = 'flasklog')\n\n        logginggroup.add_argument('--logfocus',\n                help = 'name of a logger to focus on',\n                default = argparse.SUPPRESS)\n\n\n        logginggroup.add_argument(\n            '--slowcutoff',\n            dest = 'logging_slowcutoff',\n            metavar = \"SLOWCUTOFF\",\n            help = 'threshold to log slow queries [default: %(default)s]',\n            default = 0.1,\n            type = float)\n\n        logginggroup.add_argument('--slowlogfile',\n                help = 'logfile for slow queries [default: %(default)s]',\n                dest = 'logging_slowlogfile',\n                metavar = 'FILE',\n                default = 'slow_queries.log')\n\n\n        # PostgresSQL options\n        postgresqlgroup = parser.add_argument_group('PostgreSQL options')\n        postgresqlgroup.add_argument('--postgresql-host',\n                dest = 'postgresql_host',\n                metavar = 'HOST',\n                help = 'PostgreSQL server host or socket directory [default: %(default)s]',\n                default = 'devmirror.lmfdb.xyz')\n        postgresqlgroup.add_argument('--postgresql-port',\n                dest = 'postgresql_port',\n                metavar = 'PORT',\n                type = int,\n                help = 'PostgreSQL server port [default: %(default)d]',\n                default = 5432)\n\n        postgresqlgroup.add_argument('--postgresql-user',\n                dest = 'postgresql_user',\n                metavar = 'USER',\n                help = 'PostgreSQL username [default: %(default)s]',\n                default = \"lmfdb\")\n\n        postgresqlgroup.add_argument('--postgresql-pass',\n                dest = 'postgresql_password',\n                metavar = 'PASS',\n                help = 'PostgreSQL password [default: %(default)s]',\n                default = \"lmfdb\")\n\n        # undocumented options\n        parser.add_argument('--enable-profiler',\n                dest = 'profiler',\n                help=argparse.SUPPRESS,\n                action='store_true',\n                default=argparse.SUPPRESS)\n\n        # undocumented flask options\n        parser.add_argument('--enable-reloader',\n                dest='use_reloader',\n                help=argparse.SUPPRESS,\n                action='store_true',\n                default=argparse.SUPPRESS)\n\n        parser.add_argument('--disable-reloader',\n                dest='use_reloader',\n                help=argparse.SUPPRESS,\n                action='store_false',\n                default=argparse.SUPPRESS)\n\n        parser.add_argument('--enable-debugger',\n                dest='use_debugger',\n                help=argparse.SUPPRESS,\n                action = 'store_true',\n                default=argparse.SUPPRESS)\n\n        parser.add_argument('--disable-debugger',\n                dest='use_debugger',\n                help=argparse.SUPPRESS,\n                action='store_false',\n                default=argparse.SUPPRESS)\n        if os.path.split(sys.argv[0])[-1] == \"start-lmfdb.py\" or writeargstofile:\n            args = parser.parse_args()\n        else:\n            # only read config file\n            args = parser.parse_args([])\n        args_dict = vars(args)\n        default_arguments_dict = vars(parser.parse_args([]))\n        if writeargstofile:\n            default_arguments_dict = dict(args_dict)\n\n        del default_arguments_dict['config_file']\n\n        self.default_args = {}\n        for key, val in default_arguments_dict.iteritems():\n            sec, opt = key.split('_', 1)\n            if sec not in self.default_args:\n                self.default_args[sec] = {}\n            self.default_args[sec][opt] = str(val)\n\n\n\n        from ConfigParser import ConfigParser\n\n        # reading the config file, creating it if necessary\n        # 2/1: does config file exist?\n        if not os.path.exists(args.config_file):\n            if not writeargstofile:\n                print(\"Config file: %s not found, creating it with the default values\" % args.config_file )\n            else:\n                print(\"Config file: %s not found, creating it with the passed values\" % args.config_file )\n            _cfgp  =  ConfigParser()\n\n            # create sections\n            _cfgp.add_section('core')\n            _cfgp.add_section('web')\n            _cfgp.add_section('postgresql')\n            _cfgp.add_section('logging')\n\n\n            for sec, options in self.default_args.iteritems():\n                for opt, val in options.iteritems():\n                    _cfgp.set(sec, opt, str(val))\n\n            with open(args.config_file, 'wb') as configfile:\n                _cfgp.write(configfile)\n\n        # 2/2: reading the config file\n        _cfgp  =  ConfigParser()\n        _cfgp.read(args.config_file)\n\n\n        # 3: override specific settings\n        def all(sep = '_'):\n            ret  =  {}\n            for s in _cfgp.sections():\n                for k, v in _cfgp.items(s):\n                    ret['%s%s%s' % (s, sep, k)]  =  v\n            return ret\n\n        all_set = all()\n\n        for key, val in default_arguments_dict.iteritems():\n            # if a nondefault value was passed through command line arguments set it\n            # or if a default value was not set in the config file\n            if args_dict[key] != val or key not in all_set:\n                sec, opt = key.split('_')\n                _cfgp.set(sec, opt, str(args_dict[key]))\n\n\n        # some generic functions\n        def get(section, key):\n            return _cfgp.get(section, key)\n\n        def getint(section, key):\n            return _cfgp.getint(section, key)\n\n        def getboolean(section, key):\n            return _cfgp.getboolean(section, key)\n\n\n\n        self.flask_options = {\n                \"port\": getint('web', 'port'),\n                \"host\": get('web', 'bindip'),\n                \"debug\": getboolean('core', 'debug')\n                }\n        for opt in ['use_debugger', 'use_reloader', 'profiler']:\n            if opt in args_dict:\n                self.flask_options[opt] = args_dict[opt]\n\n        self.color = getint('core', 'color')\n\n        self.postgresql_options = {\n                \"port\": getint(\"postgresql\", \"port\"),\n                \"host\": get(\"postgresql\", \"host\"),\n                \"dbname\": \"lmfdb\"}\n\n        # optional items\n        for elt in ['user','password']:\n            if _cfgp.has_option(\"postgresql\", elt):\n                self.postgresql_options[elt] = get(\"postgresql\", elt)\n\n        self.logging_options = {'logfile': get('logging', 'logfile'), 'slowcutoff':  float(get('logging', 'slowcutoff')), 'slowlogfile': get('logging', 'slowlogfile') }\n        if \"logfocus\" in args_dict:\n            self.logging_options[\"logfocus\"] = args_dict[\"logfocus\"]\n        if _cfgp.has_option(\"logging\", \"editor\"):\n            self.logging_options[\"editor\"] = get(\"logging\", \"editor\")\n\n    def get_all(self):\n        return { 'flask_options' : self.flask_options, 'postgresql_options' : self.postgresql_options, 'logging_options' : self.logging_options}\n\n    def get_flask(self):\n        return self.flask_options\n\n    def get_color(self):\n        return self.color\n\n    def get_postgresql(self):\n        return self.postgresql_options\n\n    def get_postgresql_default(self):\n        res = dict(self.default_args[\"postgresql\"])\n        res[\"port\"] = int(res[\"port\"])\n        return res\n\n    def get_logging(self):\n        return self.logging_options\n\n\nif __name__ == '__main__':\n    Configuration(writeargstofile = True)\n", "path": "lmfdb/utils/config.py"}]}