subprocess spinnt?

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
weißned
User
Beiträge: 36
Registriert: Freitag 26. Februar 2010, 21:42

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 ;)
weißned
User
Beiträge: 36
Registriert: Freitag 26. Februar 2010, 21:42

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
BlackJack

@weißned: Hast Du schonmal `_` durch eine Funktion ersetzt, die einfach nur ihr Argument zurückgibt? Nur um `gettext` als Fehlerquelle auszuschliessen.
Dav1d
User
Beiträge: 1437
Registriert: Donnerstag 30. Juli 2009, 12:03
Kontaktdaten:

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)
Zuletzt geändert von Dav1d am Sonntag 6. Juni 2010, 17:24, insgesamt 1-mal geändert.
the more they change the more they stay the same
BlackJack

@Dav1d: Da hättest Du vielleicht noch den '/' entfernen sollen…
weißned
User
Beiträge: 36
Registriert: Freitag 26. Februar 2010, 21:42

@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
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.
weißned
User
Beiträge: 36
Registriert: Freitag 26. Februar 2010, 21:42

Jo habs probiert, genau das selbe Ergebnis :/

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