Port to Python 3

This commit is contained in:
Thomas Kolb 2020-10-07 21:42:20 +02:00
parent 37f600d9c2
commit f69c1bcb8c
3 changed files with 12 additions and 4 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# -- coding: utf-8 --
import web
@ -15,7 +15,7 @@ import magic
import mimetypes
from base64 import urlsafe_b64encode
from random import random
from StringIO import StringIO
from io import StringIO
sys.path.append(os.path.dirname(__file__))
from config import *
@ -82,8 +82,8 @@ class Pastebin:
tempFile.close()
# generate the paste's id
pasteid = urlsafe_b64encode(m.digest()[0:9])
storeName = CONF_DATA_DIR + "/" + pasteid
pasteid = urlsafe_b64encode(m.digest()[0:9]).decode('ascii')
storeName = os.path.join(CONF_DATA_DIR, pasteid)
# get the mime type and extension from the data
mimeType, ext = self.detect_file_type(tempFileName)

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
web.py == 0.61
python-magic ~= 0.4.18

6
setup_sqlite.sql Normal file
View file

@ -0,0 +1,6 @@
CREATE TABLE files (
hash TEXT NOT NULL PRIMARY KEY,
detected_type TEXT NOT NULL,
create_time INT NOT NULL,
access_time INT NOT NULL,
access_count INT UNSIGNED NOT NULL DEFAULT 0);