ich wollte mal ein kleines Skript schreiben um die Handhabung von den Valve Servern wie Counter Strike zu vereinfachen. Jetzt versuche ich gerade das hldsupdatetool.bin auszuführen, damit man die Lizenz akzeptieren kann. Leider gibt es hier ein großes Problem, und zwar wird nachdem die Lizenz ausgegeben wurde, gefragt ob man diese akzeptieren möchte. Dort steht also "Enter 'yes' to accept this agreement, 'no' to decline:", nun sollte man also yes oder no eingeben können. Leider wird dieser Satz in einer Endlosschleife immer weiter ausgegeben. Das sieht dann so aus:
Code: Alles auswählen
Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to decline: Enter 'yes' to accept this agreement, 'no' to
Der code:
Code: Alles auswählen
#!/usr/bin/env python
import os.path
from gettext import gettext as _
import urllib
import ConfigParser
import sys
import subprocess
WORKDIR = ''
CONFIGPATH = os.path.expanduser('~') + '/.pySteam'
VERSION = '0.0.1'
def main():
print _('pySteam version %s' % VERSION)
if not os.path.exists(CONFIGPATH):
print _('Seems to be first start')
print _('Creating directory %s' %CONFIGPATH)
os.mkdir(CONFIGPATH)
# create a new config file
config = ConfigParser.ConfigParser()
config.add_section('main')
config.set('main', 'workdir', CONFIGPATH)
config.write(open(CONFIGPATH + '/pysteam.config', 'w'))
config = ConfigParser.ConfigParser()
config.read(CONFIGPATH + '/pysteam.config')
# read config first
WORKDIR = config.get('main', 'workdir')
# directory exists check files now
if not os.path.exists(WORKDIR + '/hldsupdatetool.bin'):
print _('Downloading hldsupdatetool')
input = urllib.urlopen('http://www.steampowered.com/download/hldsupdatetool.bin', None, None)
output = open(WORKDIR + '/hldsupdatetool.bin', 'w')
output.write(input.read())
print _('Downloading finished')
if not os.path.exists(WORKDIR + '/steam'):
print _('You have now to accept the steam license agreement, read now?(y|n) '),
choice = raw_input()
print choice
if not choice == 'y':
sys.exit(0)
# mark as executable
subprocess.Popen(['chmod', '+x', WORKDIR + '/hldsupdatetool.bin']) # btw wie kann man dies python intern machen?
# executing hldsupdatetool.bin to show agreement
subprocess.Popen(WORKDIR + '/hldsupdatetool.bin')
if __name__ == '__main__':
main()