当前位置: 首页>>代码示例>>Python>>正文


Python core.VFS类代码示例

本文整理汇总了Python中fofix.core.VFS的典型用法代码示例。如果您正苦于以下问题:Python VFS类的具体用法?Python VFS怎么用?Python VFS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了VFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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})
开发者ID:arielenter,项目名称:fofix,代码行数:27,代码来源:MainMenu.py

示例2: _getTagLine

def _getTagLine():
    from fofix.core 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)")
    else:
        return None
开发者ID:fofix,项目名称:fofix,代码行数:32,代码来源:Version.py

示例3: 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()
开发者ID:htvu,项目名称:fofix,代码行数:7,代码来源:Player.py

示例4: 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()
开发者ID:htvu,项目名称:fofix,代码行数:14,代码来源:Player.py

示例5: __init__

    def __init__(self, prototype, fileName=None, type=0):
        """
        @param prototype:  The configuration prototype mapping
        @param fileName:   The file that holds this configuration registry
        """
        self.prototype = prototype

        # read configuration
        self.config = MyConfigParser()

        if fileName:
            if not os.path.isfile(fileName):
                path = VFS.getWritableResourcePath()
                fileName = os.path.join(path, fileName)
            self.config.read(fileName)

        self.fileName = fileName
        self.type = type

        # fix the defaults and non-existing keys
        for section, options in prototype.items():
            if not self.config.has_section(section):
                self.config.add_section(section)
            for option in options.keys():
                type = options[option].type
                default = options[option].default
                if not self.config.has_option(section, option):
                    self.config.set(section, option, str(default))
开发者ID:htvu,项目名称:fofix,代码行数:28,代码来源:Config.py

示例6: 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)
开发者ID:htvu,项目名称:fofix,代码行数:29,代码来源:Player.py

示例7: 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()
开发者ID:htvu,项目名称:fofix,代码行数:16,代码来源:Player.py

示例8: 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
开发者ID:htvu,项目名称:fofix,代码行数:38,代码来源:Player.py

示例9: 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('UPDATE `players` SET `loaded` = 0')
    _playerDB.commit()
开发者ID:htvu,项目名称:fofix,代码行数:36,代码来源:Player.py

示例10: load_config

    def load_config(configPath):
        ''' Load the configuration file. '''
        if configPath is not None:
            if configPath.lower() == "reset":

                # Get os specific location of config file, and remove it.
                fileName = os.path.join(VFS.getWritableResourcePath(), Version.PROGRAM_UNIXSTYLE_NAME + ".ini")
                os.remove(fileName)

                # Recreate it
                config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)

            else:
                # Load specified config file
                config = Config.load(configPath, setAsDefault = True)
        else:
            # Use default configuration file
            config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)

        return config
开发者ID:gitter-badger,项目名称:fofix,代码行数:20,代码来源:FoFiX.py

示例11: open

import fretwork

from fretwork import log

from fofix.core import Version
from fofix.core import VFS

# setup the logfile
# File object representing the logfile.
if os.name == "posix": # evilynux - logfile in ~/.fofix/ for GNU/Linux and MacOS X
    # evilynux - Under MacOS X, put the logs in ~/Library/Logs
    if os.uname()[0] == "Darwin":
        logFile = open(os.path.expanduser('~/Library/Logs/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME), 'w')
    else: # GNU/Linux et al.
        logFile = VFS.open('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME, 'w')
else:
    logFile = VFS.open('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME, 'w')

log.setLogfile(logFile)

import fretwork
fretworkRequired = (0, 2, 0)
reqVerStr = '.'.join([str(i) for i in fretworkRequired])
fretworkErrorStr = '''

The version of fretwork installed is old. Please install the latest version from github.
https://github.com/fofix/fretwork/releases/
Installed: {0}
Required: {1}
'''
开发者ID:gitter-badger,项目名称:fofix,代码行数:30,代码来源:FoFiX.py

示例12: __init__

    def __init__(self):

        self.logClassInits = Config.get("game", "log_class_inits")
        if self.logClassInits == 1:
            log.debug("Controls class init (Player.py)...")
        self.controls = []
        self.controls.append(Config.get("game", "control0"))
        self.controls.append(Config.get("game", "control1"))
        self.controls.append(Config.get("game", "control2"))
        self.controls.append(Config.get("game", "control3"))
        self.config = []
        self.controlList = []
        self.maxplayers = 0
        self.guitars    = 0
        self.drums      = 0
        self.mics       = 0
        self.overlap    = []

        self.p2Nav = Config.get("game", "p2_menu_nav")
        self.drumNav = Config.get("game", "drum_navigation")

        self.keyCheckerMode = Config.get("game","key_checker_mode")

        if VFS.isfile(_makeControllerIniName(self.controls[0])):
            self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[0])), type = 1))
            if VFS.isfile(_makeControllerIniName(self.controls[1])) and self.controls[1] != "None":
                self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[1])), type = 1))
            else:
                self.config.append(None)
                Config.set("game", "control1", None)
                self.controls[1] = "None"
            if VFS.isfile(_makeControllerIniName(self.controls[2])) and self.controls[2] != "None":
                self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[2])), type = 1))
            else:
                self.config.append(None)
                Config.set("game", "control2", None)
                self.controls[2] = "None"
            if VFS.isfile(_makeControllerIniName(self.controls[3])) and self.controls[3] != "None":
                self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[3])), type = 1))
            else:
                self.config.append(None)
                Config.set("game", "control3", None)
                self.controls[3] = "None"
        else:
            confM = None
            if Microphone.supported:
                confM = Config.load(VFS.resolveRead(_makeControllerIniName("defaultm")), type = 1)
            self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName("defaultg")), type = 1))
            self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName("defaultd")), type = 1))
            self.config.append(confM)
            self.config.append(None)
            Config.set("game", "control0", "defaultg")
            Config.set("game", "control1", "defaultd")
            self.controls = ["defaultg", "defaultd"]
            if confM is not None:
                Config.set("game", "control2", "defaultm")
                self.controls.append("defaultm")
            else:
                Config.set("game", "control2", None)
                self.controls.append("None")
            Config.set("game", "control3", None)
            self.controls.append("None")

        self.type       = []
        self.analogKill = []
        self.analogSP   = []
        self.analogSPThresh = []
        self.analogSPSense  = []
        self.analogDrum = [] #FIXME: Analog Drum
        self.analogSlide = []
        self.analogFX   = [] #FIXME: Analog FX
        self.twoChord   = []
        self.micDevice  = []  #stump
        self.micTapSensitivity = []
        self.micPassthroughVolume = []

        self.flags = 0

        for i in self.config:
            if i:
                type = i.get("controller", "type")
                if type == 5:
                    self.mics += 1
                elif type > 1:
                    self.guitars += 1
                else:
                    self.drums += 1
                self.type.append(type)
                self.analogKill.append(i.get("controller", "analog_kill"))
                self.analogSP.append(i.get("controller", "analog_sp"))
                self.analogSPThresh.append(i.get("controller", "analog_sp_threshold"))
                self.analogSPSense.append(i.get("controller", "analog_sp_sensitivity"))
                self.analogDrum.append(i.get("controller", "analog_drum")) #FIXME: Analog Drum
                self.analogSlide.append(i.get("controller", "analog_slide"))
                self.analogFX.append(i.get("controller", "analog_fx")) #FIXME: Analog FX
                self.micDevice.append(i.get("controller", "mic_device"))  #stump
                self.micTapSensitivity.append(i.get("controller", "mic_tap_sensitivity"))
                self.micPassthroughVolume.append(i.get("controller", "mic_passthrough_volume"))
                self.twoChord.append(i.get("controller", "two_chord_max"))
                self.controlList.append(i.get("controller", "name"))
#.........这里部分代码省略.........
开发者ID:htvu,项目名称:fofix,代码行数:101,代码来源:Player.py

示例13: renameControl

def renameControl(control, newname):
    VFS.rename(_makeControllerIniName(control), _makeControllerIniName(newname))
    for i in range(4):
        if Config.get("game", "control%d" % i) == control:
            Config.set("game", "control%d" % i, newname)
    loadControls()
开发者ID:htvu,项目名称:fofix,代码行数:6,代码来源:Player.py

示例14: _

Config.define("controller", "mic_passthrough_volume", float, 0.0, text = _("Passthrough Volume"), options=dict((n / 100.0, n) for n in range(101)), tipText = _("Sets how loud you hear yourself singing.")) #stump

Config.define("player", "name",          str,  "")
Config.define("player", "difficulty",    int,  Song.MED_DIF)
Config.define("player", "part",          int,  Song.GUITAR_PART)
Config.define("player", "neck",          str,  "")
Config.define("player", "necktype",      str,  2, text = _("Neck Type"),     options = {0: _("Default Neck"), 1: _("Theme Neck"), 2: _("Specific Neck")})
Config.define("player", "leftymode",     int,  0, text = _("Lefty Mode"),    options = {0: _("Off"), 1: _("On")})
Config.define("player", "drumflip",      int,  0, text = _("Drum Flip"),     options = {0: _("Off"), 1: _("On")})
Config.define("player", "two_chord_max", int,  0, text = _("Two-Chord Max"), options = {0: _("Off"), 1: _("On")})
Config.define("player", "assist_mode",   int,  0, text = _("Assist Mode"),   options = {0: _("Off"), 1: _("Easy Assist"), 2: _("Medium Assist")})
Config.define("player", "auto_kick",     int,  0, text = _("Auto Kick"),     options = {0: _("Off"), 1: _("On")})
Config.define("player", "controller",    int,  0)

# Overlay the users folder in /data with one in the user data folder.
VFS.mount(VFS.resolveRead('/data/users'), 'users')
VFS.mountWritable(VFS.resolveWrite('/userdata/users'), 'users')
controlpath = '/users/controllers'
playerpath = '/users/players'


def _makeControllerIniName(name):
    '''Turn a controller name into a virtual path to the appropriate ini.'''
    return '%s/%s.ini' % (controlpath, name)

def _makePlayerIniName(name):
    '''Turn a player name into a virtual path to the appropriate ini.'''
    return '%s/%s.ini' % (playerpath, name)

control0 = None
control1 = None
开发者ID:htvu,项目名称:fofix,代码行数:31,代码来源:Player.py

示例15:

import fretwork

from fretwork import log

from fofix.core import Version
from fofix.core import VFS

# setup the logfile
# logfile in ~/.fofix/ for GNU/Linux and MacOS X
if os.name == "posix":
    # Under MacOS X, put the logs in ~/Library/Logs
    if os.uname()[0] == "Darwin":
        logfile = os.path.expanduser('~/Library/Logs/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME)
    else: # GNU/Linux et al.
        logfile = VFS.resolveWrite('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME)
else:
    logfile = VFS.resolveWrite('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME)
log.configure(logfile)
logger = logging.getLogger(__name__)

fretworkRequired = (0, 4, 0)
reqVerStr = '.'.join([str(i) for i in fretworkRequired])
fretworkErrorStr = '''

The version of fretwork installed is old. Please install the latest version from github.
https://github.com/fofix/fretwork/releases/
Installed: {0}
Required: {1}
'''
# The first version of fretwork didnt have __version__
开发者ID:fofix,项目名称:fofix,代码行数:30,代码来源:FoFiX.py


注:本文中的fofix.core.VFS类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。