diff options
author | James Meyer <james.meyer@operamail.com> | 2012-08-31 00:30:30 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-08-31 00:30:30 (GMT) |
commit | ed45f4ac79d137c31ea98d86982e4a2806459936 (patch) | |
tree | 767ebd8268e0c148f9b8342dbf5ebf30e419e9e4 /abs | |
parent | 58cf4165d872bc3f6254c83a52e932075809d3c1 (diff) | |
download | linhes_pkgbuild-ed45f4ac79d137c31ea98d86982e4a2806459936.zip linhes_pkgbuild-ed45f4ac79d137c31ea98d86982e4a2806459936.tar.gz linhes_pkgbuild-ed45f4ac79d137c31ea98d86982e4a2806459936.tar.bz2 |
supplemental-web: remove references to /home/mythtv
Diffstat (limited to 'abs')
-rw-r--r-- | abs/core/supplemental-web/grabkey.py | 143 |
1 files changed, 79 insertions, 64 deletions
diff --git a/abs/core/supplemental-web/grabkey.py b/abs/core/supplemental-web/grabkey.py index 2ecdd53..d079607 100644 --- a/abs/core/supplemental-web/grabkey.py +++ b/abs/core/supplemental-web/grabkey.py @@ -9,103 +9,118 @@ import sys import os def readkeyfile(): - global keylist - try: - infile = open('/data/home/mythtv/.ssh/authorized_keys', 'r') - except(IOError), e: - keylist='' - else: - keylist = infile.readlines() - infile.close() + global keylist + global data_config + try: + f = "%s/.ssh/authorized_keys" %data_config.MYTHHOME + infile = open(f, 'r') + except(IOError), e: + keylist='' + else: + keylist = infile.readlines() + infile.close() def grabkey(server): - global numberlines - global mbekey - url="http://" + server + ":1337/serverkey.cgi" - - try: - f = urllib2.urlopen(url) - except urllib2.HTTPError, e: - if e.code != 200: - print 'error find key' - sys.exit(1) - else: - mbekey = f.readlines() - f.close() + global numberlines + global mbekey + global data_config + url="http://" + server + ":1337/serverkey.cgi" + + try: + f = urllib2.urlopen(url) + except urllib2.HTTPError, e: + if e.code != 200: + print 'error find key' + sys.exit(1) + else: + mbekey = f.readlines() + f.close() numberlines = len(mbekey) #print mbekey def makenewkeyfile(): - global keylist - global mbekey - global numberlines - global numinserts - numinserts=0 - outlist = [] - for item in keylist: - if item not in outlist: - outlist.append(item) - - for item in mbekey: + global keylist + global mbekey + global numberlines + global numinserts + global data_config + numinserts=0 + outlist = [] + for item in keylist: + if item not in outlist: + outlist.append(item) + + for item in mbekey: # line = item.rstrip() - #nline = "%s #" % (line) - #nline = nline + '\n' - if item not in outlist: - outlist.append(item) - #print "adding: " + item - numinserts = numinserts + 1 - if numinserts > 0: - try: - outfile = open("/data/home/mythtv/.ssh/authorized_keys","w") - except(IOError), e: - os.system('mkdir -p /data/home/mythtv/.ssh') - outfile = open("/data/home/mythtv/.ssh/authorized_keys","w") - for i in outlist: - outfile.write(i + '\n' ) - outfile.close - os.system('chown -R mythtv /data/home/mythtv/.ssh') - os.system('chmod 700 /data/home/mythtv/.ssh/authorized_keys') - + #nline = "%s #" % (line) + #nline = nline + '\n' + if item not in outlist: + outlist.append(item) + #print "adding: " + item + numinserts = numinserts + 1 + if numinserts > 0: + f = "%s/.ssh/authorized_keys" %data_config.MYTHHOME + try: + outfile = open(f,"w") + except(IOError), e: + os.system('mkdir -p %s/.ssh' %data_config.MYTHHOME) + outfile = open(f,"w") + for i in outlist: + outfile.write(i + '\n' ) + outfile.close + os.system('chown -R mythtv %s/.ssh' %data_config.MYTHHOME ) + os.system('chmod 700 %s' %f) + global infile global keylist global numberlines global numinserts global mbekey +global data_config +sys.path.append('/usr/MythVantage/bin/') +config_file = "mv_config" +data_config = __import__(config_file, globals(), locals(), []) + + + numinserts = 0 readkeyfile() #print numberlines #print mbekey +#data_config.MYTHHOME + + try: - infile = open('/etc/systemconfig', 'r') + infile = open('/etc/systemconfig', 'r') except(IOError), e: - sys.exit(1) + sys.exit(1) else: - keylist = infile.readlines() - infile.close() + keylist = infile.readlines() + infile.close() for item in keylist: - if item.startswith("dbhost"): - itemlist=item.split("=") - server=itemlist[1].strip() - server=server.rstrip() - server=server.strip('"') - server=server.rstrip('"') + if item.startswith("dbhost"): + itemlist=item.split("=") + server=itemlist[1].strip() + server=server.rstrip() + server=server.strip('"') + server=server.rstrip('"') grabkey(server) if numberlines > 0: - makenewkeyfile() + makenewkeyfile() else: - print "nothing to add" + print "nothing to add" if numinserts < 1: - sys.exit(1) + sys.exit(1) else: - sys.exit(0) + sys.exit(0) |