import sys
import urllib2

def link_and_load(address, username, objs):
    urllib2.urlopen(urllib2.Request(address, 'op=set_input&username=user_manager&element_type=V&value="%s"' % username)).read()

    sys.path.append("interface/HUTN")
    from hutn_compiler.linker import link
    link(address, username, objs)

if __name__ == "__main__":
    if len(sys.argv) < 4:
        sys.stderr.write("Expected different parameters!\n")
        sys.stderr.write("    %s address username [files]*\n")
    else:
        address = sys.argv[1]
        username = sys.argv[2]
        objs = sys.argv[3:]

        link_and_load(address, username, objs)
