From a5e72f0fbdedf251e90334657856f07bca725be0 Mon Sep 17 00:00:00 2001 From: yo momma Date: Tue, 3 Feb 2026 22:05:50 +0000 Subject: Hump.fm: update configs and scripts --- scripts/emailposter.py | 7 +++---- scripts/fill.image_altars.py | 2 +- scripts/fill.image_urls.py | 18 +++++++++++++----- scripts/fix_fav_counts.py | 3 +-- scripts/hiscores.py | 2 +- scripts/idgi/rename.sh | 2 +- scripts/logreport.py | 2 +- scripts/s3upload.py | 8 +++++--- 8 files changed, 26 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/emailposter.py b/scripts/emailposter.py index b1dddf2..dbdc82c 100755 --- a/scripts/emailposter.py +++ b/scripts/emailposter.py @@ -57,14 +57,14 @@ def is_image(name): return l.endswith('jpg') or l.endswith('gif') or l.endswith('png') or l.endswith('jpeg') def upload_image(fname, data): - resp = post_multipart('dump.fm', '/upload/photo', - [['room', 'dumpfm']], + resp = post_multipart('hump.fm', '/upload/photo', + [['room', 'humpfm']], [['image', fname, data]]) print resp def fetch_msg(): pop_conn = poplib.POP3_SSL('pop.secureserver.net') - pop_conn.user('post@dump.fm') + pop_conn.user('post@hump.fm') pop_conn.pass_('UHR4Moghu5a2') numMessages = len(pop_conn.list()[1]) @@ -102,4 +102,3 @@ while True: - diff --git a/scripts/fill.image_altars.py b/scripts/fill.image_altars.py index 8321ffa..1181214 100755 --- a/scripts/fill.image_altars.py +++ b/scripts/fill.image_altars.py @@ -5,7 +5,7 @@ import sys import postgresql from urllib.parse import urlparse -db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db = postgresql.open("pq://postgres:root@localhost/humpfm") db.execute("SET CLIENT_ENCODING to 'UNICODE'") def get_highest_message_id_in_db(): diff --git a/scripts/fill.image_urls.py b/scripts/fill.image_urls.py index b7e0f2e..d3a10de 100755 --- a/scripts/fill.image_urls.py +++ b/scripts/fill.image_urls.py @@ -5,7 +5,7 @@ import sys import postgresql from urllib.parse import urlparse -db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db = postgresql.open("pq://postgres:root@localhost/humpfm") db.execute("SET CLIENT_ENCODING to 'UNICODE'") def get_num_images_in_db(): @@ -58,15 +58,23 @@ def get_urls_from_messages(messages): return urls # this does 3 things... -# convert 'http://dumpfm.s3.amazonaws.com' to '/' +# convert archive URLs to a shorter local form # drops 'http://' from urls -# drops 'dump.fm/images' from urls +# drops 'hump.fm/images' from urls # the client is expected to rebuild urls based on this heuristic: # if the url starts with '/', prepend '/' # otherwise, prepend 'http://' def make_url_smaller(url): - if url[:37] == 'http://dumpfm.s3.amazonaws.com/images': - url = '/images' + url[37:] + prefixes = [ + 'https://archive.hump.fm/images', + 'http://archive.hump.fm/images', + 'https://s3.amazonaws.com/archive.hump.fm/images', + 'http://s3.amazonaws.com/archive.hump.fm/images', + ] + for prefix in prefixes: + if url[:len(prefix)] == prefix: + url = '/images' + url[len(prefix):] + break if url[:21] == '/images': url = url[21:] else: diff --git a/scripts/fix_fav_counts.py b/scripts/fix_fav_counts.py index 0472488..2d6660a 100755 --- a/scripts/fix_fav_counts.py +++ b/scripts/fix_fav_counts.py @@ -28,7 +28,7 @@ import postgresql import redis import csv -db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db = postgresql.open("pq://postgres:root@localhost/humpfm") db.execute("SET CLIENT_ENCODING to 'UNICODE'") r = redis.Redis("192.168.156.111") @@ -110,4 +110,3 @@ if __name__ == "__main__": load_faves_by_user() load_faves_by_date() print("done!") - diff --git a/scripts/hiscores.py b/scripts/hiscores.py index b81269e..c4328c6 100755 --- a/scripts/hiscores.py +++ b/scripts/hiscores.py @@ -5,7 +5,7 @@ import sys import postgresql import redis -db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db = postgresql.open("pq://postgres:root@localhost/humpfm") db.execute("SET CLIENT_ENCODING to 'UNICODE'") r = redis.Redis("localhost") diff --git a/scripts/idgi/rename.sh b/scripts/idgi/rename.sh index 18af639..30eca21 100755 --- a/scripts/idgi/rename.sh +++ b/scripts/idgi/rename.sh @@ -7,6 +7,6 @@ while read LINE NEWL=${NEWL/%jpg/removed.jpg} NEWL=${NEWL/%jpeg/removed.jpeg} NEWL=${NEWL/%png/removed.png} - CMDLINE="mv /home/dumpfmprod/prod/$LINE /home/dumpfmprod/prod/$NEWL" + CMDLINE="mv /home/humpfmprod/prod/$LINE /home/humpfmprod/prod/$NEWL" $CMDLINE done diff --git a/scripts/logreport.py b/scripts/logreport.py index 88bceaf..3e6dbaf 100755 --- a/scripts/logreport.py +++ b/scripts/logreport.py @@ -18,7 +18,7 @@ Nickset = None MaxRequestTime = 10 SlowReqThreshold = 1000 WindowInterval = datetime.timedelta(minutes=5) -ConnStr = "dbname=dumpfm user=postgres password=root" +ConnStr = "dbname=humpfm user=postgres password=root" def fetch_nicks(): try: diff --git a/scripts/s3upload.py b/scripts/s3upload.py index f39ea19..f3e7cd5 100755 --- a/scripts/s3upload.py +++ b/scripts/s3upload.py @@ -6,13 +6,15 @@ import time import S3 CONN = None -AWS_ACCESS_KEY_ID = 'AKIAIVBEMR22OOG7OMMQ' -AWS_SECRET_ACCESS_KEY = '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' -BUCKET_NAME = 'dumpfm' +AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') +AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') +BUCKET_NAME = os.environ.get('HUMPFM_S3_BUCKET', 'humpfm') def get_or_initialize_aws_connection(): global CONN if not CONN: + if not AWS_ACCESS_KEY_ID or not AWS_SECRET_ACCESS_KEY: + raise Exception("Missing AWS credentials (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY)") print "Initializing AWS connection with ID %s, bucket %s" % (AWS_ACCESS_KEY_ID, BUCKET_NAME) CONN = S3.AWSAuthConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) -- cgit v1.2.3-70-g09d2