def run(use_pty=True, cmd=None, start_clojurescript_repl=False): # pyqt embedded webkit server_chan = chan.Chan() terminal_url = terminal.Terminal.create_url() def run_emulation(window_control): req = None while True: res, req = setup_and_dispatch(server_chan=server_chan, cmd=cmd, use_pty=use_pty, terminal_url=terminal_url, start_clojurescript_repl=start_clojurescript_repl, initial_request=req, window_control=window_control) if res == 'reload': pass else: return res # pyqt embedded webkit takes over now # puts all requests into server_chan webkitwindow.WebkitWindow.run(handler=SchirmHandler(server_chan, run_emulation), url=terminal_url + '/term.html', no_focus_classname='webkitwindow-no-focus')
def __init__(self, topic_name, msgtype, init_node=False, sub = None): self.init_node = init_node self.data = None self.channel = chan.Chan() self.topic_name = topic_name self.msgtype = msgtype if self.init_node: rospy.init_node('listener', anonymous=True)
def register(self, event): """ Register yourself for an event, you will receive a channel that receives any events that are triggered for the event. :parameter event: The event to register for. :returns: :class:`chan.Chan` """ c = chan.Chan(buflen=5) self.events[event].append(c) return c
def start(self): # Check if we aren't already running if self.running.is_set(): return # Now start our book keeper init = chan.Chan() self.keeper_thread = start_thread(self.book_keeper, init) init.get() # Fill up with audio files to preload for _ in range(self.preload_count): self.manager.emit("preload_new_song", True) self.running.set()
import sys import chan import youtube_dl c = chan.Chan() def dl_from_link(lnk): split = lnk.split('#')[0].split('/') if len(split) < 6: return False board = split[3] post_id = split[5] posts = c.get_thread(board, post_id) if posts.status_code != 200: return False postsj = posts.json()['posts'] thread_name = postsj[0]['semantic_url'] com = postsj[0]['com'].split('<br>')[0] if 'com' in postsj[0] else '' sdir = com if len(com) > len(thread_name) else thread_name sdir = sdir.replace('/', '_') ydl_opts = { # TODO: use longest of the two - first line of first comment or semantic url 'outtmpl': sdir + '/%(title)s.%(ext)s', 'format': 'bestaudio/best', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', # 'preferredquality': '192', }], }