def main(self): self.message_handler = message.MessageHandler() self.soc = self.message_handler.KCHAN while (True): i, o, e = select.select([self.soc], [], [], None) m = self.message_handler.recv() assert m[0] == message.OpenLink, "wrong message type" subprocess.call(["$QUARK_CROOT/link/show.sh " + m[1]], shell=True)
def __init__(self): ## Configure global config, debug, trace config = configparser.ConfigParser() config.read(('baclog.ini', 'local.ini')) bind = config.get('Client', 'bind') port = config.getint('Client', 'port') print "BacLog.run> init:", (bind, port) ## I/O scheduler and drivers self.scheduler = scheduler.init() self.mh = message.MessageHandler(bind, port) self.scheduler.addHandler(self.mh)
def main(self): self.thread_lock = threading.Lock() self.shm_obj = None self.sem_obj = None self.message_handler = message.MessageHandler() self.soc = self.message_handler.KCHAN # socket.fromfd(int(sys.argv[1]), msg.FAMILY, msg.TYPE) gobject.io_add_watch(self.soc.fileno(), gobject.IO_IN, self.handle_input) gobject.io_add_watch(self.soc.fileno(), gobject.IO_HUP, self.handle_hup) window = gtk.Window() #gtk.WINDOW_TOPLEVEL) window.set_decorated(False) window.set_app_paintable(True) screen = window.get_screen() rgba = screen.get_rgba_colormap() window.set_colormap(rgba) window.set_title("Quark Web Browser Output") vsize = config.ydimension window.set_default_size(1100, vsize - 200) #window.set_keep_above(True) window.set_decorated(False) window.connect("destroy", self.window_destroyed) window.connect('expose-event', self.expose) #window.move(100,300) window.move(63, 143) self.win = window window.show_all() (x, y, width, height, depth) = self.win.window.get_geometry() #width = 4000 #height = 4000 #self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) gtk.main()
def __init__(self): ## Configure global config,debug,trace config=configparser.ConfigParser() config.read(('baclog.ini','local.ini')) bind=config.get('Network','bind') port=config.getint('Network','port') print "BacLog.run> init:", (bind, port) if config.getboolean('Options','quiet'): debug=False trace=False ## I/O scheduler and drivers self.scheduler=scheduler.init() self.mh=message.MessageHandler(bind,port) self.scheduler.addHandler(self.mh) self.dbh=database.DatabaseHandler(port=config.getint('Database','baclogPort'), database=config.get('Database','baclogDB')) self.scheduler.addHandler(self.dbh) self.dbs=database.DatabaseHandler(port=config.getint('Database','bacsetPort'), database=config.get('Database','bacsetDB')) self.scheduler.addHandler(self.dbs)
def main(self): #tlog("tab is initiated") #fstat = os.stat(sys.argv[0]) #os.seteuid(fstat[stat.ST_UID]) #opt.parse_options(sys.argv[4:]) # opt.parse_options(["-l","-m","-k"]) # tlog("tab argv:" + str(sys.argv)) #self.tab_origin = sys.argv[2] self.escaped = None self.message_handler = message.MessageHandler() m = self.message_handler.recv() assert m[0] == message.DomainSet self.tab_origin = m[1] libsoup.soup_set_t2k_raw_socket(int(sys.argv[1])) #if opt.options.use_kcookies: # cookie cache is always on. #libsoup.soup_set_kcookies_flag(1) # create a pair of sockets for cookies cparent, cchild = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) self.message_handler.send([message.CookieChannelInit, cchild]) libsoup.soup_set_t2c_raw_socket(int(cparent.fileno())) print "t2c_socket is set" self.cookie_soc = cparent self.cookie_soc.setblocking(1) gobject.io_add_watch(self.cookie_soc.fileno(), gobject.IO_IN, self.handle_cinput) #gtk.timeout_add(500, lambda : gobject.io_add_watch(self.cookie_soc.fileno(), gobject.IO_IN, self.handle_cinput)) self.cmessage_handler = message.MessageHandler(self.cookie_soc) #self.soc = socket.fromfd(int(sys.argv[1]), msg.FAMILY, msg.TYPE) self.soc = self.message_handler.KCHAN self.soc.setblocking(1) self.shm_obj = create_memory(5000000) self.shm_obj.attach() self.sem_obj = shm.create_semaphore(self.shm_obj.shmid, 1) self.sem_obj.setperm(0600) self.sem_obj.setuid(quarkexec.quark_output_uid) self.sem_obj.setblocking(True) gobject.io_add_watch(self.soc.fileno(), gobject.IO_IN, self.handle_input) gobject.io_add_watch(self.soc.fileno(), gobject.IO_HUP, self.handle_hup) self.view = webkit.WebView() self.view.connect('expose-event', self.expose) self.view.connect('resource-request-starting', self.resource_cb) self.view.connect('notify::progress', self.progress_cb) self.view.connect('navigation-policy-decision-requested', self.navigation_cb) self.view.connect('create-web-view', self.create_web_view_cb) #self.view.connect('notify::load-status', self.load_status_cb) settings = self.view.get_settings() settings.set_property("enable-plugins", False) self.frames = {} win = gtk.OffscreenWindow() vsize = config.ydimension win.set_default_size(1100, vsize - 200) win.add(self.view) #vbox = gtk.VBox(False, 0) #win.add(vbox) #vbox.show() #addr_bar = gtk.Entry(max=0) #addr_bar.set_text("hello world!") #vbox.pack_start(addr_bar, True, True, 0) #addr_bar.show() #vbox.add(self.view) #win.add(self.view) self.view.show() win.connect('damage-event', self.damage) win.show_all() #self.vbox = vbox self.win = win (x, y, width, height, depth) = self.view.get_window().get_geometry() #(x,y,width,height,depth) = self.win.get_window().get_geometry() #print self.win.get_window() #raise "aa" #(x,y,width,height,depth) = self.win.get_window().get_geometry() self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) #self.tab_origin = sys.argv[2] #m = msg.create_display_shm(self.shm_obj.shmid, 0) #self.write_message(m) tlog("default url : " + self.add_http(self.tab_origin)) #self.view.open(self.add_http(self.tab_origin)) #gtk.timeout_add(50, self.iterated_render) #self.rthread = threading.Thread(target=self.drawing_thread, args=()) #self.rthread.start() #t_thread = threading.Thread(target=self.input_thread, args=()) #t_thread.start() gtk.main()
# ['/usr/bin/wget', # '-q', # '--convert-links', # '-O', '-', # '-U', user_agent, # uri], # bufsize = 1, # stdin = subprocess.PIPE, # stdout = subprocess.PIPE).communicate()[0] fname = "webfile" subprocess.call([ '/usr/bin/wget', '--tries=1', '--timeout=0.5', '-q', '--convert-links', '-O', fname, '-U', user_agent, uri ]) f = open(fname) content = f.read() f.close() return content #pickle.dump(get_uri(sys.argv[1]), sys.stdout) #print get_uri(sys.argv[1]) message_handler = message.MessageHandler() message_handler.KCHAN.send(get_uri(sys.argv[3])) #sys.stdout.write(get_uri(sys.argv[1])) #USER_AGENT="Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30" #echo "=============================================" >> wget.out #echo "ORIGIN:$1" >> wget.out #/usr/bin/wget --tries=1 --timeout=2 --server-response --convert-links -a wget.out -O webfile -U "$USER_AGENT" $2 2>>wget.err
def run(self): #self.soc = socket.fromfd(int(sys.argv[1]), msg.FAMILY, msg.TYPE) print sys.argv self.message_handler = message.MessageHandler() self.ksock = self.message_handler.KCHAN print "cookie initialization:begin" m = self.message_handler.recv() assert m[0] == message.DomainSet self.name = m[1] print "cookie initialization:end:%s" % self.name #opt.parse_options(sys.argv[3:]) try: f = open("cookies/" + self.name) self.cookie_db = pickle.load(f) f.close except : clog("cookie file loading failed") self.cookie_db = {} signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGABRT, signal_handler) while (True): i,o,e = select.select(self.tabs + [self.ksock],[],[],None) clog("cookie %s received a message " % self.name) for s in i: message_handler = message.MessageHandler(s) m = message_handler.recv() mtype = m[0] if s == self.ksock : clog("kernel sent a message:") if mtype == message.TabProcessRegister : clog("tab register message : %s " % str(m[1].fileno())) self.tabs.append(socket.fromfd(m[1].fileno(), socket.AF_UNIX, socket.SOCK_STREAM)) else : clog("Invalid message type from kernel :%d " % mtype) #sys.exit(1) c.exit() elif mtype == message.CookieJarRequest : # this is not a uri. this is a formatted data string by the tab data = m[1] idx = string.find(data, ";") first = data[0:idx] idx2 = string.find(data, ";", idx + 1) second = data[idx + 1 : idx2] idx3 = string.rfind(data, ";") third = data[idx2 + 1 : idx3] fourth = data[idx3 + 1:] cookies = self.get_cookies(first,second,third, bool(int(fourth))) print "cookie process sends :%d" % len(cookies) message.MessageHandler(s).send( [message.CookieJarResponse, cookies]) elif mtype == message.CookieUpdate : self.add_cookie(m[1]) for t in self.tabs : if t != s : message.MessageHandler(t).send( [message.CookieBroadcast, m[1]]) else : clog("Invalid message type :%d " % mtype) sys.exit(1)
def __init__(self, service): self.service = service self.message_handler = message.MessageHandler(self.service)
def handle_message(**payload): """Passing the message payload to message_handler . """ handler_instance = message.MessageHandler(payload) handler_instance.handle()