def handle(self, *args, **options): geiss_github_name = self.get_geiss_github_name() download_file = get_geiss_path() if os.path.isfile(download_file): # Geiss does probably exist. Do nothing. # TODO: Add an update flag, that Geiss is downloaded anyway. return release = self.get_release() download_url = None for asset in release['assets']: if asset['name'] == geiss_github_name: download_url = asset['browser_download_url'] break if download_url is None: raise CommandError("Could not find download URL in release.") urlretrieve(download_url, download_file) # Set the executable bit on the file. This will do nothing on windows st = os.stat(download_file) os.chmod(download_file, st.st_mode | stat.S_IEXEC) self.stdout.write( self.style.SUCCESS('Geiss {} successfully downloaded.'.format( release['tag_name'])))
def handle(self, *args, **options): geiss_github_name = self.get_geiss_github_name() download_file = get_geiss_path() if os.path.isfile(download_file): # Geiss does probably exist. Do nothing. # TODO: Add an update flag, that downloads geiss anyway. return response = urlopen(self.get_geiss_url()).read() release = json.loads(response.decode()) download_url = None for asset in release['assets']: if asset['name'] == geiss_github_name: download_url = asset['browser_download_url'] break if download_url is None: raise CommandError("Could not find download URL in release.") urlretrieve(download_url, download_file) # Set the executable bit on the file. This will do nothing on windows st = os.stat(download_file) os.chmod(download_file, st.st_mode | stat.S_IEXEC) self.stdout.write(self.style.SUCCESS('Geiss successfully downloaded.'))
def start(args): """ Starts OpenSlides: Runs migrations and runs runserver. """ settings_dir = args.settings_dir settings_filename = args.settings_filename local_installation = is_local_installation() if settings_dir is None: if local_installation: settings_dir = get_local_settings_dir() else: settings_dir = get_default_settings_dir() # Write django settings if it does not exists. settings_path = os.path.join(settings_dir, settings_filename) if not os.path.isfile(settings_path): createsettings(args) # Set the django setting module and run migrations # A manual given environment variable will be overwritten setup_django_settings_module(settings_path, local_installation=local_installation) django.setup() from django.conf import settings if args.debug_email: settings.EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Migrate database call_command('migrate') if args.use_geiss: # Make sure Redis is used. if settings.CHANNEL_LAYERS['default']['BACKEND'] != 'asgi_redis.RedisChannelLayer': raise RuntimeError("You have to use the ASGI Redis backend in the settings to use Geiss.") # Download Geiss and collect the static files. call_command('getgeiss') call_command('collectstatic', interactive=False) # Open the browser if not args.no_browser: open_browser(args.host, args.port) # Start Geiss in its own thread subprocess.Popen([ get_geiss_path(), '--host', args.host, '--port', args.port, '--static', '/static/:{}'.format(settings.STATIC_ROOT), '--static', '/media/:{}'.format(settings.MEDIA_ROOT), ]) # Start one worker in this thread. There can be only one worker as # long as SQLite3 is used. call_command('runworker') else: # Open the browser if not args.no_browser: open_browser(args.host, args.port) # Start Daphne and one worker # # Use flag --noreload to tell Django not to reload the server. # Therefor we have to set the keyword noreload to False because Django # parses this directly to the use_reloader keyword. # # Use flag --insecure to serve static files even if DEBUG is False. # # Use flag --nothreading to tell Django Channels to run in single # thread mode with one worker only. Therefor we have to set the keyword # nothreading to False because Django parses this directly to # use_threading keyword. call_command( 'runserver', '{}:{}'.format(args.host, args.port), noreload=False, # Means True, see above. insecure=True, nothreading=False, # Means True, see above. )
def start(args): """ Starts OpenSlides: Runs migrations and runs runserver. """ settings_path = args.settings_path local_installation = is_local_installation() if settings_path is None: if local_installation: settings_path = get_local_settings_path() else: settings_path = get_default_settings_path() # Write settings if it does not exists. if not os.path.isfile(settings_path): createsettings(args) # Set the django setting module and run migrations # A manual given environment variable will be overwritten setup_django_settings_module(settings_path, local_installation=local_installation) django.setup() from django.conf import settings # Migrate database call_command('migrate') if args.use_geiss: # Make sure Redis is used. if settings.CHANNEL_LAYERS['default']['BACKEND'] != 'asgi_redis.RedisChannelLayer': raise RuntimeError("You have to use the ASGI Redis backend in the settings to use Geiss.") # Download Geiss and collect the static files. call_command('getgeiss') call_command('collectstatic', interactive=False) # Open the browser if not args.no_browser: open_browser(args.host, args.port) # Start Geiss in its own thread subprocess.Popen([ get_geiss_path(), '--host', args.host, '--port', args.port, '--static', '/static/:{}'.format(settings.STATIC_ROOT), '--static', '/media/:{}'.format(settings.MEDIA_ROOT), ]) # Start one worker in this thread. There can be only one worker as # long as SQLite3 is used. call_command('runworker') else: # Open the browser if not args.no_browser: open_browser(args.host, args.port) # Start Daphne and one worker # # Use flag --noreload to tell Django not to reload the server. # Therefor we have to set the keyword noreload to False because Django # parses this directly to the use_reloader keyword. # # Use flag --insecure to serve static files even if DEBUG is False. # # Use flag --nothreading to tell Django Channels to run in single # thread mode with one worker only. Therefor we have to set the keyword # nothreading to False because Django parses this directly to # use_threading keyword. call_command( 'runserver', '{}:{}'.format(args.host, args.port), noreload=False, # Means True, see above. insecure=True, nothreading=False, # Means True, see above. )