本文整理汇总了Python中VFS类的典型用法代码示例。如果您正苦于以下问题:Python VFS类的具体用法?Python VFS怎么用?Python VFS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deletePlayer
def deletePlayer(player):
_playerDB.execute('DELETE FROM `players` WHERE `name` = ?', [player])
VFS.unlink(_makePlayerIniName(player))
if VFS.isfile('%s/%s.png' % (playerpath, player)):
VFS.unlink('%s/%s.png' % (playerpath, player))
savePlayers()
loadPlayers()
示例2: shown
def shown(self):
self.engine.view.pushLayer(self.menu)
shaders.checkIfEnabled()
if not self.shownOnce:
self.shownOnce = True
if hasattr(sys, 'frozen'):
# Check whether this is a release binary being run from an svn/git
# working copy or whether this is an svn/git binary not being run
# from an corresponding working copy.
currentVcs, buildVcs = None, None
if VFS.isdir('/gameroot/.git'):
currentVcs = 'git'
elif VFS.isdir('/gameroot/src/.svn'):
currentVcs = 'Subversion'
if 'git' in Version.version():
buildVcs = 'git'
elif 'svn' in Version.version():
buildVcs = 'Subversion'
if currentVcs != buildVcs:
if buildVcs is None:
msg = _('This binary release is being run from a %(currentVcs)s working copy. This is not the correct way to run FoFiX from %(currentVcs)s. Please see one of the following web pages to set your %(currentVcs)s working copy up correctly:') + \
'\n\nhttp://code.google.com/p/fofix/wiki/RunningUnderPython26' + \
'\nhttp://code.google.com/p/fofix/wiki/RequiredSourceModules'
else:
msg = _('This binary was built from a %(buildVcs)s working copy but is not running from one. The FoFiX Team will not provide any support whatsoever for this binary. Please see the following site for official binary releases:') + \
'\n\nhttp://code.google.com/p/fofix/'
Dialogs.showMessage(self.engine, msg % {'buildVcs': buildVcs, 'currentVcs': currentVcs})
示例3: deleteControl
def deleteControl(control):
VFS.unlink(_makeControllerIniName(control))
defaultUsed = -1
for i in range(4):
get = Config.get("game", "control%d" % i)
if get == control:
if i == 0:
Config.set("game", "control%d" % i, "defaultg")
defaultUsed = 0
else:
Config.set("game", "control%d" % i, None)
if get == "defaultg" and defaultUsed > -1:
Config.set("game", "control%d" % i, None)
loadControls()
示例4: updatePlayer
def updatePlayer(player, pref):
a = _playerDB.execute('SELECT * FROM `players` WHERE `name` = ?', [player]).fetchone()
try:
a = a[0]
except:
a = None
if a is not None:
_playerDB.execute('UPDATE `players` SET `name` = ?, `lefty` = ?, `drumflip` = ?, `autokick` = ?, `assist` = ?, `twochord` = ?, `necktype` = ?, `neck` = ?, \
`part` = 0, `difficulty` = 2, `upname` = ?, `control` = 0, `changed` = 1, `loaded` = 1 WHERE `name` = ?', pref + [player])
if player != pref[0]:
VFS.rename(_makePlayerIniName(player), _makePlayerIniName(pref[0]))
else:
_playerDB.execute('INSERT INTO `players` VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, 2, ?, 0, 1, 1)', pref)
_playerDB.commit()
savePlayers()
loadPlayers()
示例5: loadControls
def loadControls():
global controllerDict
controllers = []
allcontrollers = VFS.listdir(controlpath)
default = ["defaultd.ini", "defaultg.ini", "defaultm.ini"]
for name in allcontrollers:
if name.lower().endswith(".ini") and len(name) > 4:
if name in default:
continue
controllers.append(name[0:len(name)-4])
i = len(controllers)
controllerDict = dict([(str(controllers[n]),controllers[n]) for n in range(0, i)])
controllerDict["defaultg"] = _("Default Guitar")
controllerDict["defaultd"] = _("Default Drum")
defMic = None
if Microphone.supported:
controllerDict["defaultm"] = _("Default Microphone")
defMic = "defaultm"
tsControl = _("Controller %d")
tsControlTip = _("Select the controller for slot %d")
i = 1
Config.define("game", "control0", str, "defaultg", text = tsControl % 1, options = controllerDict, tipText = tsControlTip % 1)
controllerDict[_("None")] = None
Config.define("game", "control1", str, "defaultd", text = tsControl % 2, options = controllerDict, tipText = tsControlTip % 2)
Config.define("game", "control2", str, defMic, text = tsControl % 3, options = controllerDict, tipText = tsControlTip % 3)
Config.define("game", "control3", str, None, text = tsControl % 4, options = controllerDict, tipText = tsControlTip % 4)
示例6: _getTagLine
def _getTagLine():
import VFS # can't be done at top level due to circular import issues...
# Look for a git repository.
if VFS.isdir("/gameroot/.git"):
# HEAD is in the form "ref: refs/heads/master\n"
headref = VFS.open("/gameroot/.git/HEAD").read()[5:].strip()
if VFS.isfile("/gameroot/.git/" + headref):
# The ref is in the form "sha1-hash\n"
headhash = VFS.open("/gameroot/.git/" + headref).read().strip()
else:
# It's a packed ref.
for line in VFS.open("/gameroot/.git/packed-refs"):
if line.strip().endswith(headref):
headhash = line[:40]
break
shortref = re.sub("^refs/(heads/)?", "", headref)
return "development (git %s %s)" % (shortref, headhash[:7])
# Look for the svn administrative directory.
elif VFS.isdir("/gameroot/src/.svn"):
revision = VFS.open("/gameroot/src/.svn/entries").readlines()[3].strip()
return "development (svn r%s)" % revision
else:
return None
示例7: _getTagLine
def _getTagLine():
import VFS # can't be done at top level due to circular import issues...
# Look for a git repository.
if VFS.isdir('/gameroot/.git'):
# HEAD is in the form "ref: refs/heads/master\n"
headref = VFS.open('/gameroot/.git/HEAD').read()[5:].strip()
# The ref is in the form "sha1-hash\n"
headhash = VFS.open('/gameroot/.git/' + headref).read().strip()
shortref = re.sub('^refs/(heads/)?', '', headref)
return 'development (git %s %s)' % (shortref, headhash[:7])
# Look for the svn administrative directory.
elif VFS.isdir('/gameroot/src/.svn'):
revision = VFS.open('/gameroot/src/.svn/entries').readlines()[3].strip()
return 'development (svn r%s)' % revision
else:
return None
示例8: open
def open(self, path, flags, mode=None):
if path in self._openFiles:
return -errno.EAGAIN
access = flags & (os.O_RDONLY | os.O_RDWR | os.O_WRONLY)
if access == os.O_RDONLY:
omode = 'rb'
elif flags & os.O_TRUNC:
omode = 'w+b'
elif flags & os.O_APPEND:
omode = 'a+b'
else:
omode = 'r+b'
self._openFiles[path] = VFS.open(path, omode)
示例9: loadPlayers
def loadPlayers():
global playername, playerpref, playerstat
playername = []
playerpref = []
playerstat = []
allplayers = VFS.listdir(playerpath)
for name in allplayers:
if name == "default.ini":
continue
if name.lower().endswith(".ini") and len(name) > 4:
playername.append(name[0:len(name)-4])
pref = _playerDB.execute('SELECT * FROM `players` WHERE `name` = ?', [playername[-1]]).fetchone()
try:
if len(pref) == 14:
playerpref.append((pref[1], pref[2], pref[3], pref[4], pref[5], pref[6], pref[7], pref[8], pref[9], pref[10]))
except TypeError:
try:
c = Config.load(VFS.resolveRead(_makePlayerIniName(name[:-4])), type = 2)
lefty = c.get("player","leftymode")
drumf = c.get("player","drumflip")
autok = c.get("player","auto_kick")
assist = c.get("player","assist_mode")
twoch = c.get("player","two_chord_max")
neck = c.get("player","neck")
neckt = c.get("player","necktype")
part = c.get("player","part")
diff = c.get("player","difficulty")
upname = c.get("player","name")
control= c.get("player","controller")
del c
_playerDB.execute('INSERT INTO `players` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 1)', [playername[-1], lefty, drumf, autok, assist, twoch, neckt, neck, part, diff, upname, control])
playerpref.append((lefty, drumf, autok, assist, twoch, neckt, neck, part, diff, upname))
except IOError:
_playerDB.execute('INSERT INTO `players` VALUES (?, 0, 0, 0, 0, 0, 0, ``, 0, 2, ``, 0, 0, 1)', [playername[-1]])
playerpref.append((0, 0, 0, 0, 0, 0, '', 0, 2, '', 0))
_playerDB.execute('UPDATE `players` SET `loaded` = 1 WHERE `name` = ?', [playername[-1]])
_playerDB.commit()
return 1
示例10: GetInfoMedia
def GetInfoMedia (self, source):
# Download file input file, if needed
local_in = VFS.local_reference (source)
assert local_in[0] == '/', "A local copy of the file is required"
# Video Converter
infor = converters.VideoInfo()
dict_info = infor.get (local_in)
# Check the information retrieved
if not dict_info:
return "failed"
return ("ok", dict_info)
示例11: savePlayers
def savePlayers():
for pref in _playerDB.execute('SELECT * FROM `players` WHERE `changed` = 1').fetchall():
try:
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
c.set("player","leftymode",int(pref[1]))
c.set("player","drumflip",int(pref[2]))
c.set("player","auto_kick",int(pref[3]))
c.set("player","assist_mode",int(pref[4]))
c.set("player","two_chord_max",int(pref[5]))
c.set("player","necktype",int(pref[6]))
c.set("player","neck",str(pref[7]))
c.set("player","part",int(pref[8]))
c.set("player","difficulty",int(pref[9]))
c.set("player","name",str(pref[10]))
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
except:
c = VFS.open(_makePlayerIniName(str(pref[0])), "w")
c.close()
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
c.set("player","leftymode",int(pref[1]))
c.set("player","drumflip",int(pref[2]))
c.set("player","auto_kick",int(pref[3]))
c.set("player","assist_mode",int(pref[4]))
c.set("player","two_chord_max",int(pref[5]))
c.set("player","necktype",int(pref[6]))
c.set("player","neck",str(pref[7]))
c.set("player","part",int(pref[8]))
c.set("player","difficulty",int(pref[9]))
c.set("player","name",str(pref[10]))
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
#_playerDB.execute('DELETE FROM `players` WHERE `loaded` = 0')
_playerDB.execute('UPDATE `players` SET `loaded` = 0')
_playerDB.commit()
示例12: BuildThumbnailMedia
def BuildThumbnailMedia (self, source, target):
# Download file input file, if needed
local_in = VFS.local_reference (source)
assert local_in[0] == '/', "A local copy of the file is required"
# Video Converter
thumbnailer = converters.VideoThumbnail()
thumbnailer.generate (local_in, target)
# Check the new file
if not os.path.exists (target):
return "failed"
if os.path.getsize (target) < 1:
return "failed"
return "ok"
示例13: ConvertMedia
def ConvertMedia (self, source, target, format):
# Download file input file, if needed
local_in = VFS.local_reference (source)
assert local_in[0] == '/', "A local copy of the file is required"
# Video Converter
vc = converters.VideoConverter()
args = (local_in, target, format)
task_id = (int(time.time()*10**6)) & 0xFFFFFFF
callback = processors.FileCallback (task_id)
self.jobs.put ((vc.convert, args, callback, task_id))
status.status[task_id] = -1
return task_id
示例14: _getTagLine
def _getTagLine():
import VFS # can't be done at top level due to circular import issues...
# Look for a git repository.
if VFS.isdir('/gameroot/.git'):
shortref = None
headhash = None
# HEAD is in the form "ref: refs/heads/master\n" if a branch is
# checked out, or just the hash if HEAD is detached.
refline = VFS.open('/gameroot/.git/HEAD').read().strip()
if refline[0:5] == "ref: ":
headref = refline[5:]
if VFS.isfile('/gameroot/.git/' + headref):
# The ref is in the form "sha1-hash\n"
headhash = VFS.open('/gameroot/.git/' + headref).read().strip()
else:
# It's a packed ref.
for line in VFS.open('/gameroot/.git/packed-refs'):
if line.strip().endswith(headref):
headhash = line[:40]
break
shortref = re.sub('^refs/(heads/)?', '', headref)
else:
shortref = "(detached)"
headhash = refline
return 'development (git %s %s)' % (shortref or "(unknown)",
headhash and headhash[:7] or "(unknown)")
# Look for the svn administrative directory.
elif VFS.isdir('/gameroot/src/.svn'):
revision = VFS.open('/gameroot/src/.svn/entries').readlines()[3].strip()
return 'development (svn r%s)' % revision
else:
return None
示例15: truncate
def truncate(self, path, offset):
f = VFS.open(path, 'ab')
f.truncate(offset)
f.close()