mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-23 16:19:49 -05:00
Fix parameter passing and work with chromiums wrapper stuff
This commit is contained in:
parent
db9eee5f2b
commit
7b219ab011
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
python -m umbra.umbra
|
python -m umbra.umbra $@
|
||||||
|
|
||||||
|
@ -37,8 +37,7 @@ class Umbra:
|
|||||||
self.fetch_url("http://archive.org")
|
self.fetch_url("http://archive.org")
|
||||||
self.fetch_url("http://facebook.com")
|
self.fetch_url("http://facebook.com")
|
||||||
self.fetch_url("http://flickr.com")
|
self.fetch_url("http://flickr.com")
|
||||||
time.sleep(10)
|
print("Ctrl + C to exit")
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def send_command(self,tab=None, **kwargs):
|
def send_command(self,tab=None, **kwargs):
|
||||||
if not tab:
|
if not tab:
|
||||||
@ -68,16 +67,13 @@ class Chrome():
|
|||||||
import psutil, subprocess
|
import psutil, subprocess
|
||||||
self.chrome_process = subprocess.Popen([self.executable, "--temp-profile", "--remote-debugging-port=%s" % self.port])
|
self.chrome_process = subprocess.Popen([self.executable, "--temp-profile", "--remote-debugging-port=%s" % self.port])
|
||||||
start = time.time()
|
start = time.time()
|
||||||
open_debug_port = lambda conn: conn.laddr[1] == int(self.port)
|
import socket
|
||||||
chrome_ps_wrapper = psutil.Process(self.chrome_process.pid)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
while time.time() - start < float(self.browser_wait) and len(list(filter(open_debug_port, chrome_ps_wrapper.get_connections()))) == 0:
|
while sock.connect_ex(('127.0.0.1',int(self.port))) != 0 and (time.time() - start) < float(self.browser_wait):
|
||||||
time.sleep(1)
|
time.sleep(0.1)
|
||||||
if len(list(filter(open_debug_port, chrome_ps_wrapper.get_connections()))) == 0:
|
|
||||||
self.chrome_process.kill()
|
|
||||||
raise Exception("Chrome failed to listen on the debug port in time!")
|
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
print("Killing")
|
|
||||||
self.chrome_process.kill()
|
self.chrome_process.kill()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user