Compare commits

..

No commits in common. "b32d5aa6c6fb9a1542db46037dd1600028e66ce8" and "ca94704e4ef18858f9a6efcd8dd3f03ac735bf70" have entirely different histories.

5 changed files with 5 additions and 548 deletions

38
test.py
View File

@ -1,38 +0,0 @@
import os
import os.path
import ssl
import stat
import subprocess
import sys
STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
| stat.S_IROTH | stat.S_IXOTH )
def main():
openssl_dir, openssl_cafile = os.path.split(
ssl.get_default_verify_paths().openssl_cafile)
print(" -- pip install --upgrade certifi")
subprocess.check_call([sys.executable,
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
import certifi
# change working directory to the default SSL directory
os.chdir(openssl_dir)
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
print(" -- removing any existing file or link")
try:
os.remove(openssl_cafile)
except FileNotFoundError:
pass
print(" -- creating symlink to certifi certificate bundle")
os.symlink(relpath_to_certifi_cafile, openssl_cafile)
print(" -- setting permissions")
os.chmod(openssl_cafile, STAT_0o775)
print(" -- update complete")
if __name__ == '__main__':
main()

View File

@ -5,8 +5,6 @@ import os
from progress.bar import Bar from progress.bar import Bar
from wand.image import Image from wand.image import Image
import worldmap import worldmap
import warnings
warnings.filterwarnings("ignore")
from bookstack import Bookstack from bookstack import Bookstack
@ -125,8 +123,8 @@ def update_films_by_country_page(token_id, token_secret):
with Bar('Generating table', max=country_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar: with Bar('Generating table', max=country_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
film_by_country_table = build_table(viewings_by_country, bar) film_by_country_table = build_table(viewings_by_country, bar)
print("Drawing map")
country_counter = Counter(viewings_by_country) country_counter = Counter(viewings_by_country)
png_data = draw_map(country_counter) png_data = draw_map(country_counter)
update_page(png_data, film_by_country_table, VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret) update_page(png_data, film_by_country_table, VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret)

View File

@ -31,7 +31,7 @@ def update_films_by_year_page(token_id, token_secret):
viewing_count = len(viewings) viewing_count = len(viewings)
with Bar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar: with Bar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
VCinemaUtils.add_imdb_data_to_viewings(viewings, ['year'], bar) VCinemaUtils.add_imdb_data_to_viewings(viewings, bar)
with Bar('Processing viewing data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar: with Bar('Processing viewing data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
viewings_by_year = VCinemaUtils.filter_viewings(viewings, 'year', bar) viewings_by_year = VCinemaUtils.filter_viewings(viewings, 'year', bar)

View File

@ -11,13 +11,11 @@ def update_viewings_csv_file_from_page(token_id, token_secret):
# Page ID of https://wiki.jacknet.io/books/vcinema/page/csv # Page ID of https://wiki.jacknet.io/books/vcinema/page/csv
page_id = 11 page_id = 11
print("Retrieving viewings page")
html_page = Bookstack.get_page_html(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, page_id) html_page = Bookstack.get_page_html(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, page_id)
soup = BeautifulSoup(html_page, 'html.parser') soup = BeautifulSoup(html_page, 'html.parser')
csv_data = soup.find("code").text.strip().encode('utf-8') csv_data = soup.find("code").text.strip().encode('utf-8')
print("Retrieving existing file")
existing_attachment_id = VCinemaUtils.get_viewings_csv_attachment_id(token_id, token_secret) existing_attachment_id = VCinemaUtils.get_viewings_csv_attachment_id(token_id, token_secret)
attachment = Bookstack.get_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id) attachment = Bookstack.get_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id)
@ -27,13 +25,13 @@ def update_viewings_csv_file_from_page(token_id, token_secret):
page_hash = hashlib.md5(csv_data).hexdigest() page_hash = hashlib.md5(csv_data).hexdigest()
if page_hash != existing_attachment_hash: if page_hash != existing_attachment_hash:
print("Updating file") print("updating file")
# bookstack update file via api doesn't work # bookstack update file via api doesn't work
Bookstack.post_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, "vcinema.csv", csv_data, page_id) Bookstack.post_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, "vcinema.csv", csv_data, page_id)
Bookstack.delete_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id) Bookstack.delete_attachment(VCinemaUtils.JACKNET_WIKI_URL, token_id, token_secret, existing_attachment_id)
print("Done") print("done")
else: else:
print("File already up to date") print("file already up to date")
if __name__ == '__main__': if __name__ == '__main__':

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 1.3 MiB