Example #1
0
 def handle_noargs(self, base_dir=None, **options):
     if base_dir is None:
         base_dir = os.path.dirname(__file__)
         for i in range(__package__.count('.') + 1):
             base_dir = os.path.dirname(base_dir)
     mod_dir = os.path.join(base_dir, 'openeis', 'local')
     if not os.path.exists(mod_dir):
         os.makedirs(mod_dir)
     path = os.path.join(mod_dir, '__init__.py')
     if not os.path.exists(path):
         open(path, 'w').close()
     path = os.path.join(mod_dir, 'settings.py')
     if not os.path.exists(path) or options.get('force'):
         chars = ''.join(getattr(string, name) for name in
                         ['ascii_letters', 'digits', 'punctuation'])
         options['secret_key'] = repr(''.join(random.choice(chars)
                                              for i in range(50)))
         options['pm_method'] = repr({'generic': 'direct',
                                      'apache': 'X-Sendfile',
                                      'nginx': 'X-Accel-Redirect'}
                                     [options['server']])
         with clean_render():
             content = render_to_string('server/management/settings.py', options)
         with open(path, 'w') as file:
             file.write(content)
     self.stdout.write("Edit `{}' to your liking.".format(path))
Example #2
0
 def handle(self, config_file=None, **options):
     options['settings'] = settings
     with clean_render():
         content = render_to_string('server/management/nginx.conf', options)
     file = open(config_file, 'w') if config_file else sys.stdout
     try:
         file.write(content)
     finally:
         if config_file:
             file.close()
Example #3
0
 def handle(self, config_file=None, **options):
     options['settings'] = settings
     with clean_render():
         content = render_to_string('server/management/nginx.conf', options)
     file = open(config_file, 'w') if config_file else sys.stdout
     try:
         file.write(content)
     finally:
         if config_file:
             file.close()