import os try: import simplejson as sj except ImportError: import json as sj import urllib2 import base64 APIURL = 'http://birdy:8282/korpus/korpus/api' UNAME = 'script' PASSWD = 'parool' authheader = base64.encodestring('%s:%s' % (UNAME, PASSWD))[:-1] drive = 'E:' + os.path.sep working = ['dev', 'python'] prog_dir = working + ['pruulmann_data'] program = 'demo_ana.exe' params = 'input.txt' wpath = drive + os.path.join(*working) progpath = drive + os.path.join(*prog_dir) execut = os.path.join(progpath, program) # execut += ' '+docid # print execut # os.chdir(progpath) # # os.system(execut) # print "oi" req = urllib2.Request(APIURL+'/getWork', {}, {'Authorization': 'BASIC '+authheader}) opener = urllib2.urlopen(req) work = sj.loads(opener.read()) print work