mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-04-20 23:56:34 -04:00
read/write chromium local state
This commit is contained in:
parent
5b30d644b9
commit
dd4fce8763
@ -138,7 +138,6 @@ class Browser:
|
||||
self.chrome_port = self._find_available_port()
|
||||
self._work_dir = tempfile.TemporaryDirectory()
|
||||
data_dir = os.path.join(self._work_dir.name, "chrome-user-data")
|
||||
flags_location = os.path.join(data_dir, "Local State")
|
||||
if cookie_db is not None:
|
||||
cookie_dir = os.path.join(data_dir, "Default")
|
||||
cookie_location = os.path.join(cookie_dir, "Cookies")
|
||||
@ -154,6 +153,15 @@ class Browser:
|
||||
"exception writing cookie file at %s",
|
||||
cookie_location, exc_info=True)
|
||||
|
||||
flags_location = os.path.join(data_dir, "Local State")
|
||||
try:
|
||||
with open(flags_location, 'w+') as f:
|
||||
json.dump(make_local_state, f)
|
||||
except OSError:
|
||||
self.logger.error(
|
||||
"exception writing local state file at %s",
|
||||
flags_location, exc_info=True)
|
||||
|
||||
self._chrome_instance = Chrome(
|
||||
port=self.chrome_port, executable=self.chrome_exe,
|
||||
user_home_dir=self._work_dir.name,
|
||||
@ -205,6 +213,17 @@ class Browser:
|
||||
cookie_location, exc_info=True)
|
||||
return cookie_db
|
||||
|
||||
def make_chromium_local_state(self):
|
||||
local_state_location = '/tmp/chromium/Local State'
|
||||
with open(local_state_location) as j:
|
||||
local_state = json.load(j)
|
||||
if 'enabled_labs_experiments' in local_state['browser']:
|
||||
if 'enable-brotli@2' not in local_state['browser']['enabled_labs_experiments']:
|
||||
local_state['browser']['enabled_labs_experiments'].append('enable-brotli@2')
|
||||
else:
|
||||
local_state['browser']['enabled_labs_experiments'] = ['enable-brotli@2']
|
||||
return local_state
|
||||
|
||||
def _find_available_port(self):
|
||||
port_available = False
|
||||
port = self.chrome_port
|
||||
|
Loading…
x
Reference in New Issue
Block a user