Commit 5a865145 authored by Julian Rother's avatar Julian Rother

Initial commit

RELEASED_TMP = '/tmp/kodiert'
RAW_TMP = '/tmp/raw/autoencode/upload'
RAW_PREFIX = 'autoencode'
RAW_TARGET = '/tmp/raw/autoencode'
API_BASEURL = 'http://localhost:5000'
FTPD_PORT = 2121
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
import os
import requests
from config import *
def on_file_received(handler, path):
if path.startswith(RELEASED_TMP):
path = path[len(RELEASED_TMP):].lstrip('/')
requests.get(API_BASEURL+'/internal/sort/encoded/'+path, params={'apikey': API_APIKEY})
elif path.startswith(RAW_TMP):
path = path[len(RAW_TMP):].lstrip('/')
num = 0
suffix = ''
while os.path.exists(RAW_TARGET+'/'+path+suffix):
num += 1
suffix = '.'+str(num)
os.rename(RAW_TMP+'/'+path, RAW_TARGET+'/'+path+suffix)
path = RAW_PREFIX+'/'+path+suffix
requests.get(API_BASEURL+'/internal/sort/raw', params={'apikey': API_APIKEY, 'path': path})
print("Unknown path:", path)
authorizer = DummyAuthorizer()
authorizer.add_user('kodiert', PASSWORD, RELEASED_TMP, perm='elradfwMT') # No MKD!
authorizer.add_user('autoencode', PASSWORD, RAW_TMP, perm='elradfwMT') # No MKD!
handler = FTPHandler
handler.banner = "Video AG upload ftpd ready."
handler.authorizer = authorizer
handler.on_file_received = on_file_received
server = FTPServer((FTPD_ADDR, FTPD_PORT), handler)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment