ALT Linux Bugzilla
– Attachment 2256 Details for
Bug 10817
Пытается писать в системные директории
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
Патч, для сохранения настроек в ~/.wrw
wrw.patch (text/plain), 2.28 KB, created by
Slava Semushin
on 2007-11-07 15:15:37 MSK
(
hide
)
Description:
Патч, для сохранения настроек в ~/.wrw
Filename:
MIME Type:
Creator:
Slava Semushin
Created:
2007-11-07 15:15:37 MSK
Size:
2.28 KB
patch
obsolete
>--- auto.py.orig 2007-11-07 17:41:18 +0600 >+++ auto.py 2007-11-07 18:03:54 +0600 >@@ -4,6 +4,8 @@ import pygame > import math > import sys > import config >+from os.path import expanduser, dirname >+from os import makedirs > > COLOR_CESTA = pygame.color.Color("yellow") > COLOR_TRAVA = pygame.color.Color("green") >@@ -228,11 +230,20 @@ class Auto: > self.winnerwav.play() > config.konec = 1 > if config.besttime > config.time: >- readonly = open(config.trackFile) >+ users_trackFile = expanduser("~/.wrw/") + config.trackFile >+ try: >+ readonly = open(users_trackFile) >+ except: >+ readonly = open(config.trackFile) > content = readonly.readlines() > readonly.close() > >- score = open(config.trackFile ,"w") >+ try: >+ score = open(users_trackFile, "w") >+ except IOError: >+ makedirs(dirname(users_trackFile), 0700) >+ score = open(users_trackFile, "w") >+ > score.write(str(config.time) + "\n") > score.write(config.name + "\n") > score.write(config.car + "\n") >--- config.py.orig 2007-11-06 20:08:58 +0600 >+++ config.py 2007-11-07 17:51:53 +0600 >@@ -1,5 +1,7 @@ > > import pygame >+from os.path import expanduser >+from os import mkdir > > pl1car = "images/cars/bentley/bentleysmall.png" > pl1stin = "images/cars/bentley/bentleystin.png" >@@ -46,7 +48,10 @@ name = 'Opi' > multikola = 3 > > def readConfig(): >- source = file(configFile).read() >+ try: >+ source = file(expanduser("~/.wrw/") + configFile).read() >+ except: >+ source = file(configFile).read() > exec source in locals(), globals() > > def writeConfig(): >@@ -56,7 +61,11 @@ full = %d > name = %r > multikola = %d > """ % (rozmer, zvuky, full, name, multikola) >- output = file(configFile, "w") >+ try: >+ mkdir(expanduser("~/.wrw"), 0700) >+ except OSError: >+ pass >+ output = file(expanduser("~/.wrw/") + configFile, "w") > output.write(text) > output.close() >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 10817
:
2255
| 2256