#!/usr/bin/env python

'''
This thing should be taken out back and shot.
It served its purpose but...

It should use threading, get rid of GJ's manifest Java stuff
and use XMl-RPC exclusively.

'''

import string, sys, os
from prefs import *

''' I'm using the readline() method because Windows
has a smallish length of args I can pass :~(
'''


SSK = sys.stdin.readline()
SSK = SSK[:-1]

uploadDir = sys.stdin.readline()
uploadDir = uploadDir[:-1]

siteName = sys.stdin.readline()
siteName = siteName[:-1]

defaultFile = sys.stdin.readline()
defaultFile = defaultFile[:-1]

simRequests = sys.stdin.readline()
simRequests = simRequests[:-1]

updateInterval = sys.stdin.readline()
updateInterval = updateInterval[:-1]

HTL = sys.stdin.readline()
HTL = HTL[:-1]

cmd = ('"%s" -cp /Freenet/Freenet.jar;/Snarfzilla/Manifest.jar relentless.gj.cli.PutFiles -simRequests %s -htl %s %s -mskURIValue %s/%s -fromDir %s -rootDir %s ' % (java, simRequests, HTL, updateInterval, SSK, siteName, uploadDir, uploadDir))

os.system(cmd)

'''
sys.stdout.write(cmd)
sys.stdout.flush()
i, result, e = os.popen3(cmd)
print "Reading"
#out = o.readline()
#print out
l = result.readline()
print l
sys.stdout.write(l)
sys.stdout.flush()

while l:
    print "IN WHILE"
    l = result.readline()
    sys.stdout.write(l)
    sys.stdout.flush()

sys.stdout.flush()
sys.stderr.flush()
'''