def prepare(self): super(MainIndex, self).prepare() if not cache.get_station(self.sid, "sched_current"): raise APIException( "server_just_started", "Rainwave is Rebooting, Please Try Again in a Few Minutes", http_code=500) # self.json_payload = {} self.jsfiles = None if not self.user: self.user = User(1) self.user.ensure_api_key() if self.beta or config.get("web_developer_mode") or config.get( "developer_mode") or config.get("test_mode"): buildtools.bake_beta_css() buildtools.bake_beta_templates() self.jsfiles = [] for root, subdirs, files in os.walk( os.path.join(os.path.dirname(__file__), "../static/%s" % self.js_dir)): #pylint: disable=W0612 for f in files: if f.endswith(".js"): self.jsfiles.append( os.path.join( root[root.find("static/%s" % self.js_dir):], f))
def start(self): buildtools.bake_css() buildtools.bake_js() buildtools.bake_templates() buildtools.bake_beta_templates() buildtools.copy_woff() # Setup variables for the long poll module # Bypass Tornado's forking processes for Windows machines if num_processes is set to 1 if config.get("api_num_processes") == 1 or config.get("web_developer_mode"): self._listen(0) else: # The way this works, is that the parent PID is hijacked away from us and everything after this # is a child process. As of Tornado 2.1, fork() is used, which means we do have a complete # copy of all execution in memory up until this point and we will have complete separation of # processes from here on out. Tornado handles child cleanup and zombification. # # We can have a config directive for numprocesses but it's entirely optional - a return of # None from the config option getter (if the config didn't exist) will cause Tornado # to spawn as many processes as there are cores on the server CPU(s). tornado.process.fork_processes(config.get("api_num_processes")) task_id = tornado.process.task_id() if task_id != None: self._listen(task_id)
def prepare(self): if self.path_kwargs.get("station"): self.sid = config.stream_filename_to_sid.get( self.path_kwargs["station"]) if not self.sid: self.redirect(config.get("base_site_url")) return super(MainIndex, self).prepare() if self.path_kwargs.get("station") is None: self.redirect("{}{}/".format( config.get("base_site_url"), config.station_mount_filenames[self.sid], )) return if config.get("enforce_ssl") and self.request.protocol != "https": self.redirect("{}{}/".format( config.get("base_site_url"), config.station_mount_filenames[self.sid], )) return if not config.get("developer_mode" ) and self.request.host != config.get("hostname"): self.redirect("{}{}/".format( config.get("base_site_url"), config.station_mount_filenames[self.sid], )) return if not cache.get_station(self.sid, "sched_current"): raise APIException( "server_just_started", "Rainwave is Rebooting, Please Try Again in a Few Minutes", http_code=500, ) self.jsfiles = None if not self.user: self.user = User(1) self.user.ip_address = self.request.remote_ip self.user.ensure_api_key() if (self.beta or config.get("web_developer_mode") or config.get("developer_mode") or config.get("test_mode")): buildtools.bake_beta_css() buildtools.bake_beta_templates() self.jsfiles = [] for root, _subdirs, files in os.walk( os.path.join(os.path.dirname(__file__), "../static/%s" % self.js_dir)): for f in files: if f.endswith(".js"): self.jsfiles.append( os.path.join( root[root.find("static/%s" % self.js_dir):], f))
def prepare(self): super(MainIndex, self).prepare() if not cache.get_station(self.sid, "sched_current"): raise APIException( "server_just_started", "Rainwave is Rebooting, Please Try Again in a Few Minutes", http_code=500 ) # self.json_payload = {} self.jsfiles = None if not self.user: self.user = User(1) self.user.ip_address = self.request.remote_ip self.user.ensure_api_key() if self.beta or config.get("web_developer_mode") or config.get("developer_mode") or config.get("test_mode"): buildtools.bake_beta_css() buildtools.bake_beta_templates() self.jsfiles = [] for root, subdirs, files in os.walk( os.path.join(os.path.dirname(__file__), "../static/%s" % self.js_dir) ): # pylint: disable=W0612 for f in files: if f.endswith(".js"): self.jsfiles.append(os.path.join(root[root.find("static/%s" % self.js_dir) :], f))
def prepare(self): super(MainIndex, self).prepare() self.json_payload = {} self.jsfiles = None if not self.user: self.user = User(1) self.user.ensure_api_key() if self.beta or config.get("web_developer_mode") or config.get("developer_mode") or config.get("test_mode"): buildtools.bake_beta_css() buildtools.bake_beta_templates() self.jsfiles = [] for root, subdirs, files in os.walk( os.path.join(os.path.dirname(__file__), "../static/%s" % self.js_dir) ): # pylint: disable=W0612 for f in files: if f.endswith(".js"): self.jsfiles.append(os.path.join(root[root.find("static/%s" % self.js_dir) :], f))
def prepare(self): if self.path_kwargs.get('station'): self.sid = config.stream_filename_to_sid.get(self.path_kwargs['station']) if not self.sid: self.redirect(config.get("base_site_url")) return super(MainIndex, self).prepare() if self.path_kwargs.get('station') is None: self.redirect("{}{}/".format(config.get("base_site_url"), config.station_mount_filenames[self.sid]), permanent=True) return if config.get("enforce_ssl") and self.request.protocol != "https": self.redirect("{}{}/".format(config.get("base_site_url"), config.station_mount_filenames[self.sid]), permanent=True) return if not config.get("developer_mode") and self.request.host != config.get("hostname"): self.redirect("{}{}/".format(config.get("base_site_url"), config.station_mount_filenames[self.sid]), permanent=True) return if not cache.get_station(self.sid, "sched_current"): raise APIException("server_just_started", "Rainwave is Rebooting, Please Try Again in a Few Minutes", http_code=500) # self.json_payload = {} self.jsfiles = None if not self.user: self.user = User(1) self.user.ip_address = self.request.remote_ip self.user.ensure_api_key() if self.beta or config.get("web_developer_mode") or config.get("developer_mode") or config.get("test_mode"): buildtools.bake_beta_css() buildtools.bake_beta_templates() self.jsfiles = [] for root, subdirs, files in os.walk(os.path.join(os.path.dirname(__file__), "../static/%s" % self.js_dir)): #pylint: disable=W0612 for f in files: if f.endswith(".js"): self.jsfiles.append(os.path.join(root[root.find("static/%s" % self.js_dir):], f))