#!/usr/bin/env python

# Submits key to in-Freenet key index

# Python system stuff
import sys, os, threading

# Custom stuff:
from prefs import *

class submitKey(threading.Thread):
    def __init__(self, parent, key, index, htl):
        threading.Thread.__init__(self)
        self.setDaemon(1)
        self.key = key
        self.index = index
        self.htl = htl

    def run(self):
        #win32
        cmd = ('"%s" -cp /freenet/freenet.jar Freenet.client.KeyIndexClient -htl %s -insert %s -key %s' % (java, self.htl, self.index, self.key ))
        #cmd = ("%s -cp %s/freenet.jar Freenet.client.KeyIndexClient -htl %s -insert %s -key %s" % (java, freenetdir, self.htl, self.index, self.key ))
        print cmd
        try:
            os.system(cmd)
        except:
            print "Error submitting key"
            print sys.exc_type, sys.exc_value
