Print data from Python dictionary based on variable?
Im trying to write a simple script that makes a game run on a single
processor core, as ive heard it doesnt work very well with multicore
processors.This script chooses a random core and fires up the game, id
like it to tell me which core its starting up on. Rcore chooses a random
int from cores and uses that as the system command to start up the game.
decore is the dictionary that translates the "binary" back into human
langauge. ex
core1 = 1
core2 = 2
core3 = 4
core4 = 8
Id like to print the core its chosen in the command prompt before starting
the game, i cant figure out how to do that.
from os import system as sysc
import random
cores = [1,2,4,8]
rcore = int(random.choice(cores))
data = "\"C:\Windows\System32\cmd.exe /k start \"\" /affinity %s
\"C:\Program Files (x86)\Steam\SteamApps\common\Kerbal Space
Program\KSP.exe\"" %rcore
decore ={ 1:'1',2 :'2',4 :'3',8:'4'}
print 'Launching KSP on processor core:%s'
sysc('%s'%(data))
Heres what i tried
>>> for rcore in decore:
... print rcore
8
1
2
4
..Not the result i wanted. Is there an easy, magic way to do this? The
script does work, it works very well..it just doesnt display what i want.
No comments:
Post a Comment