-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from geopozo/neyberson/browser_protocol
Neyberson/browser protocol
- Loading branch information
Showing
10 changed files
with
119 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from .browser import Browser | ||
from .connection import Connection | ||
|
||
__all__ = [Browser, Connection] | ||
__all__ = [Browser] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from .tab import Tab | ||
from .session import Session | ||
from collections import OrderedDict | ||
|
||
|
||
class Protocol: | ||
def __init__(self, browser_pipe): | ||
self.browser_session = Session(self, session_id="") | ||
self.target_id = 0 | ||
self.tabs = OrderedDict() | ||
self.pipe = browser_pipe | ||
|
||
def create_tab(self): | ||
tab_obj = Tab() | ||
self.tabs[tab_obj.target_id] = tab_obj | ||
print(f"New Tab Created: {tab_obj.target_id}") | ||
return tab_obj | ||
|
||
def list_tabs(self): | ||
print("Tabs".center(50, "-")) | ||
for target_id in self.tabs.keys(): | ||
print(target_id.center(50, " ")) | ||
print("End".center(50, "-")) | ||
|
||
def close_tab(self, tab_id): | ||
if isinstance(tab_id, str): | ||
del self.tabs[tab_id] | ||
else: | ||
del self.tabs[tab_id.target_id] | ||
print(f"The following tab was deleted: {tab_id}") | ||
|
||
def send_command(self, command, params=None, cb=None): | ||
return self.browser_session.send_command(command, params, cb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from .session import Session | ||
from collections import OrderedDict | ||
import uuid | ||
|
||
|
||
class Tab: | ||
def __init__(self): | ||
self.tab_sessions = OrderedDict() | ||
self.target_id = str(uuid.uuid4()) | ||
|
||
def add_session(self): | ||
session_obj = Session(self) | ||
self.tab_sessions[session_obj.session_id] = session_obj | ||
print(f"New Session Added: {session_obj.session_id}") | ||
return session_obj | ||
|
||
def list_sessions(self): | ||
print("Sessions".center(50, "-")) | ||
for session_instance in self.tab_sessions.values(): | ||
print(str(session_instance.session_id).center(50, " ")) | ||
print("End".center(50, "-")) | ||
|
||
def close_session(self, session_obj): | ||
if isinstance(session_obj, str): | ||
del self.tab_sessions[session_obj] | ||
else: | ||
del self.tab_sessions[session_obj.session_id] | ||
print(f"The following session was deleted: {session_obj.session_id}") |