#!/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 *
snarfdir = os.path.abspath(os.path.join(os.getcwd(), sys.path[0]))

''' 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]
#win32
cmd = ('"%s" -cp %s/freenet.jar;/%s/Manifest.jar relentless.gj.cli.PutFiles -serverAddress %s -simRequests %s -htl %s %s -mskURIValue %s/%s -fromDir %s -rootDir %s ' % (java, freenetdir, snarfdir, serverAddress, simRequests, HTL, updateInterval, SSK, siteName, uploadDir, uploadDir))
print cmd
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()
'''