Browse Source

Add feature to disable logging

pull/31/head
Wesley Kerfoot 5 years ago
parent
commit
056fd75aae
  1. 13
      README.md
  2. 12
      deletefb/deletefb.py
  3. 3
      deletefb/tools/common.py

13
README.md

@ -49,11 +49,24 @@ requirements.txt`, then you can just run `python -m deletefb.deletefb.py` in the
* It is recommended that you disable Two-Factor Authentication tempoprarily * It is recommended that you disable Two-Factor Authentication tempoprarily
while you are running the script, in order to get the best experience. while you are running the script, in order to get the best experience.
* If you run into issues with Facebook complaining about your browser,
currently the only workaround is to manually click through them.
* If you do have 2-Factor Auth configured then the script will pause for 20 * If you do have 2-Factor Auth configured then the script will pause for 20
seconds to allow you to enter your code and log in. seconds to allow you to enter your code and log in.
* You may also pass in a code by using the `-F` argument, e.g. `-F 111111`. * You may also pass in a code by using the `-F` argument, e.g. `-F 111111`.
## Delete by year
* The tool supports passing the `--year` flag in order to delete wall posts by
year. It is incompatible with any mode other than `wall`.
## Archival
* The tool will archive everything being deleted by default in `.log` files.
Currently they are simply stored as JSON objects for each line in the log. It
will archive the content, and a timestamp if it is available. You may disable
this feature by using `--no-archive`.
## Headless mode ## Headless mode
* The tool supports running Chrome in headless mode with the `--headless` * The tool supports running Chrome in headless mode with the `--headless`
option, which may be preferable if you plan on running it in the background. option, which may be preferable if you plan on running it in the background.

12
deletefb/deletefb.py

@ -4,6 +4,7 @@ import argparse
import getpass import getpass
from sys import exit from sys import exit
from os import environ
from .tools.login import login from .tools.login import login
from .tools.wall import delete_posts from .tools.wall import delete_posts
from .tools.likes import unlike_pages from .tools.likes import unlike_pages
@ -67,6 +68,14 @@ def run_delete():
help="Run browser in headless mode (no gui)" help="Run browser in headless mode (no gui)"
) )
parser.add_argument(
"--no-archive",
action="store_true",
dest="archive_off",
default=True,
help="Turn off archiving (on by default)"
)
parser.add_argument( parser.add_argument(
"-Y", "-Y",
"--year", "--year",
@ -78,6 +87,9 @@ def run_delete():
args = parser.parse_args() args = parser.parse_args()
if args.archive_off:
environ["DELETEFB_ARCHIVE"] = "false" if args.archive_off else "true"
if args.year and args.mode != "wall": if args.year and args.mode != "wall":
parser.error("The --year option is only supported in wall mode") parser.error("The --year option is only supported in wall mode")

3
deletefb/tools/common.py

@ -4,6 +4,7 @@ from selenium.common.exceptions import (NoSuchElementException,
from time import sleep from time import sleep
from json import dumps from json import dumps
from os.path import abspath, relpath, split from os.path import abspath, relpath, split
from os import environ
SELENIUM_EXCEPTIONS = (NoSuchElementException, SELENIUM_EXCEPTIONS = (NoSuchElementException,
StaleElementReferenceException, StaleElementReferenceException,
@ -30,6 +31,8 @@ def archiver(category):
log_file = open(log_path, mode="wt", buffering=1) log_file = open(log_path, mode="wt", buffering=1)
def log(content, timestamp=False): def log(content, timestamp=False):
if environ.get("DELETEFB_ARCHIVE", "true") == "false":
return
structured_content = { structured_content = {
"category" : category, "category" : category,
"content" : content, "content" : content,

Loading…
Cancel
Save