Browse Source

Fix bugs with archiver

pull/53/head
Wesley Kerfoot 5 years ago
parent
commit
f159937e1d
  1. 2
      deletefb/tools/archive.py
  2. 7
      deletefb/tools/common.py
  3. 5
      deletefb/tools/likes.py
  4. 7
      deletefb/tools/wall.py

2
deletefb/tools/archive.py

@ -32,7 +32,7 @@ class Archive:
print("Archiving {0}".format(content))
if content.name not in self._bloom_filter:
self.archive_file.write(json.dumps(attr.asdict(content)))
self.archive_file.write(json.dumps(attr.asdict(content)) + "\n")
self._bloom_filter.add(content.name)
return

7
deletefb/tools/common.py

@ -6,6 +6,7 @@ from selenium.common.exceptions import (
TimeoutException
)
import datetime
import json
import logging
import logging.config
@ -18,6 +19,12 @@ SELENIUM_EXCEPTIONS = (
TimeoutException
)
def timestamp_now():
"""
Returns: a timestamp for this instant, in ISO 8601 format
"""
return datetime.datetime.isoformat(datetime.datetime.now())
def click_button(driver, el):
"""
Click a button using Javascript

5
deletefb/tools/likes.py

@ -1,12 +1,11 @@
from .archive import archiver
from .common import SELENIUM_EXCEPTIONS, logger, click_button
from .common import SELENIUM_EXCEPTIONS, logger, click_button, timestamp_now
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
import attr
import datetime
LOG = logger(__name__)
@ -14,7 +13,7 @@ LOG = logger(__name__)
@attr.s
class Page:
name = attr.ib()
date = attr.ib(factory=datetime.datetime.now)
date = attr.ib(factory=timestamp_now)
def load_likes(driver, profile_url):
"""

7
deletefb/tools/wall.py

@ -1,10 +1,9 @@
from .archive import archiver
from .common import SELENIUM_EXCEPTIONS, click_button
from .common import SELENIUM_EXCEPTIONS, click_button, timestamp_now
from .config import settings
from selenium.webdriver.common.action_chains import ActionChains
import attr
import datetime
import time
import uuid
@ -13,14 +12,14 @@ import uuid
class Post:
content = attr.ib()
comments = attr.ib(default=[])
date = attr.ib(factory=datetime.datetime.now)
date = attr.ib(factory=timestamp_now)
name = attr.ib(factory=lambda: uuid.uuid4().hex)
@attr.s
class Comment:
commenter = attr.ib()
content = attr.ib()
date = attr.ib(factory=datetime.datetime.now)
date = attr.ib(factory=timestamp_now)
name = attr.ib(factory=lambda: uuid.uuid4().hex)
# Used as a threshold to avoid running forever

Loading…
Cancel
Save