Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def persistent_firefox():
if not os.path.exists(PROFILE_DIR):
os.makedirs(PROFILE_DIR)
print("Kibitzr is running Firefox in persistent profile mode.")
with firefox(headless=False) as driver:
driver.get(HOME_PAGE)
while True:
prompt_return()
try:
# Property raises when browser is closed:
driver.title
except:
# All kinds of things happen when closing Firefox
break
else:
update_profile(driver)
print(
"Firefox profile is saved. "
def update_profile(driver):
if os.path.exists(PROFILE_DIR):
shutil.rmtree(PROFILE_DIR)
shutil.copytree(
driver.capabilities['moz:profile'],
PROFILE_DIR,
ignore=shutil.ignore_patterns(
"parent.lock",
"lock",
".parentlock",
"*.sqlite-shm",
"*.sqlite-wal",
),
def update_profile(driver):
if os.path.exists(PROFILE_DIR):
shutil.rmtree(PROFILE_DIR)
shutil.copytree(
driver.capabilities['moz:profile'],
PROFILE_DIR,
ignore=shutil.ignore_patterns(
"parent.lock",
"lock",
".parentlock",
"*.sqlite-shm",
"*.sqlite-wal",
),
def update_profile(driver):
if os.path.exists(PROFILE_DIR):
shutil.rmtree(PROFILE_DIR)
shutil.copytree(
driver.capabilities['moz:profile'],
PROFILE_DIR,
ignore=shutil.ignore_patterns(
"parent.lock",
"lock",
".parentlock",
"*.sqlite-shm",
"*.sqlite-wal",
),