Seite 1 von 1

subprocess spinnt?

Verfasst: Donnerstag 3. Juni 2010, 22:04
von weißned
Hi Leute,

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
und das geht immer so weiter Oo

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()
Danke schon mal ;)

Re: subprocess spinnt?

Verfasst: Samstag 5. Juni 2010, 23:23
von weißned
Weiß da niemand was?

Also es tritt bei python 2.6 und 2.5 auf. Es tritt auch bei os.system() auf, aber wenn ich das in IDLE versuche, dann gehts Oo

Re: subprocess spinnt?

Verfasst: Samstag 5. Juni 2010, 23:52
von BlackJack
@weißned: Hast Du schonmal `_` durch eine Funktion ersetzt, die einfach nur ihr Argument zurückgibt? Nur um `gettext` als Fehlerquelle auszuschliessen.

Re: subprocess spinnt?

Verfasst: Sonntag 6. Juni 2010, 15:28
von Dav1d
In der letzten Zeile der Funktion `main`

Code: Alles auswählen

subprocess.Popen(WORKDIR + '/hldsupdatetool.bin')
sollte doch so:

Code: Alles auswählen

subprocess.Popen([os.path.join(WORKDIR, 'hldsupdatetool.bin')])
lauten (os.path.join verwendet, weils dafür "erfunden" wurde ;))

//Edit: '/' entfernt (siehe BlackJack unter mir :P)

Re: subprocess spinnt?

Verfasst: Sonntag 6. Juni 2010, 16:11
von BlackJack
@Dav1d: Da hättest Du vielleicht noch den '/' entfernen sollen…

Re: subprocess spinnt?

Verfasst: Sonntag 6. Juni 2010, 17:25
von weißned
@Dav1d: Danke für den Tipp!

@BlackJack: Hmm, also ich weiß nich so genau was du meinst, soll ich einfach eine Funktion machen wie:

Code: Alles auswählen

def funktion(arg):
    return arg
Dan könnte ich ja gettext auch erstmal ganz weglassen :D

Re: subprocess spinnt?

Verfasst: Sonntag 6. Juni 2010, 18:05
von BlackJack
@weißned: Ja aber so eine Funktion erscheint mir einfacher als überall das `_` zu entfernen. Lässt sich auch einfacher wieder rückgängig machen.

Re: subprocess spinnt?

Verfasst: Sonntag 6. Juni 2010, 18:12
von weißned
Jo habs probiert, genau das selbe Ergebnis :/

Ich frag mich wie so ein komischer Fehler auftreten kann -.-