MCPcopy Index your code
hub / github.com/pyload/pyload / checkVersion

Method checkVersion

module/ConfigParser.py:60–97  ·  view source on GitHub ↗

determines if config need to be copied

(self, n=0)

Source from the content-addressed store, hash-verified

58
59
60 def checkVersion(self, n=0):
61 """determines if config need to be copied"""
62 try:
63 if not exists("pyload.conf"):
64 copy(join(pypath, "module", "config", "default.conf"), "pyload.conf")
65 chmod("pyload.conf", 0600)
66
67 if not exists("plugin.conf"):
68 f = open("plugin.conf", "wb")
69 f.write("version: " + str(CONF_VERSION))
70 f.close()
71 chmod("plugin.conf", 0600)
72
73 f = open("pyload.conf", "rb")
74 v = f.readline()
75 f.close()
76 v = v[v.find(":") + 1:].strip()
77
78 if not v or int(v) < CONF_VERSION:
79 copy(join(pypath, "module", "config", "default.conf"), "pyload.conf")
80 print "Old version of config was replaced"
81
82 f = open("plugin.conf", "rb")
83 v = f.readline()
84 f.close()
85 v = v[v.find(":") + 1:].strip()
86
87 if not v or int(v) < CONF_VERSION:
88 f = open("plugin.conf", "wb")
89 f.write("version: " + str(CONF_VERSION))
90 f.close()
91 print "Old version of plugin-config replaced"
92 except:
93 if n < 3:
94 sleep(0.3)
95 self.checkVersion(n + 1)
96 else:
97 raise
98
99 def readConfig(self):
100 """reads the config file"""

Callers 1

__init__Method · 0.95

Calls 6

chmodFunction · 0.90
existsFunction · 0.85
writeMethod · 0.45
closeMethod · 0.45
readlineMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected