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


Python common.getPlatform函数代码示例

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


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

示例1: loadDefaults

    def loadDefaults(self):
        '''Load defaults. All keys are derived from these defaults.
        '''
        self.ref['directoryScratch'] = None # path to a directory for temporary files
        self.ref['lilypondPath'] = None # path to lilypond
        self.ref['lilypondVersion'] = None # version of lilypond
        self.ref['lilypondFormat'] = 'pdf' 
        self.ref['lilypondBackend'] = 'ps' 
        self.ref['musicxmlPath'] = None # path to a MusicXML reader: default, will find "Finale Reader"
        self.ref['midiPath'] = None # path to a midi reader
        self.ref['graphicsPath'] = None # path to a graphics viewer
        self.ref['showFormat'] = 'musicxml' 
        self.ref['writeFormat'] = 'musicxml' 
        self.ref['autoDownload'] = 'ask' 
        self.ref['debug'] = 0

        platform = common.getPlatform()

        if platform == 'win':
            for name, value in [
                ('lilypondPath', 'lilypond'),
                ]:
                self.__setitem__(name, value) # use for key checking
        elif platform == 'nix':
            for name, value in [('lilypondPath', 'lilypond')]:
                self.__setitem__(name, value) # use for key checking
        elif platform ==  'darwin':
            for name, value in [
                ('lilypondPath', '/Applications/Lilypond.app/Contents/Resources/bin/lilypond'),
                ('musicxmlPath', '/Applications/Finale Reader/Finale Reader.app'),
                ('graphicsPath', '/Applications/Preview.app'),
                ]:
                self.__setitem__(name, value) # use for key checking
开发者ID:knuton,项目名称:music21,代码行数:33,代码来源:environment.py

示例2: main

def main(fnAccept=None):
    '''
    `fnAccept` is a list of one or more files to test.
    '''

    mg = test.ModuleGather()

    # only accept a few file names for now
    if fnAccept in [None, []]:
        fnAccept = ['note.py']

        #fnAccept = ['stream.py', 'note.py', 'chord.py']

    disable = ['C0301', 'C0302', 'C0103', 'C0324', 'W0621', 'W0511', 
               'W0404', 'R0201', 'R0904', 'E1101', 'R0914', 'R0903',
               'R0911', 'R0902', ]

    cmd = ['pylint -f colorized']
    for id in disable:
        cmd.append('--disable=%s' % id)

    # add entire package
    for fp in mg.modulePaths:
        dir, fn = os.path.split(fp)
        fnNoExt = fn.replace('.py', '')
        if fn in fnAccept or fnNoExt in fnAccept:
            cmdFile = cmd + [fp]
            print(' '.join(cmdFile))
            if common.getPlatform() != 'win':
                os.system(' '.join(cmdFile))
开发者ID:ABC-B,项目名称:music21,代码行数:30,代码来源:testLint.py

示例3: getTempFile

    def getTempFile(self, suffix=''):
        '''
        gets a temporary file with a suffix that will work for a bit.
        note that the file is closed after finding, so some older versions
        of python/OSes, etc. will immediately delete the file.
        '''
        # get the root dir, which may be the user-specified dir
        rootDir = self.getRootTempDir()
        if len(suffix) > 0 and not suffix.startswith('.'):
            suffix = '.' + suffix


        if common.getPlatform() != 'win':
            fileDescriptor, filePath = tempfile.mkstemp(
                dir=rootDir, suffix=suffix)
            if isinstance(fileDescriptor, int):
                # on MacOS, fd returns an int, like 3, when this is called
                # in some context (specifically, programmatically in a
                # TestExternal class. the filePath is still valid and works
                pass
            else:
                fileDescriptor.close()
        else:  # win
            tf = tempfile.NamedTemporaryFile(dir=rootDir, suffix=suffix)
            filePath = tf.name
            tf.close()
        #self.printDebug([_MOD, 'temporary file:', filePath])
        return filePath
开发者ID:TimRichter,项目名称:music21,代码行数:28,代码来源:environment.py

示例4: launchGregorio

    def launchGregorio(self, fp = None):
        '''
        converts a .gabc file to LaTeX using the
        gregorio converter.  Returns the filename with .tex substituted for .gabc
        
        
        >>> bsc = chant.BaseScoreConverter()
        >>> #_DOCS_SHOW newFp = bsc.launchGregorio('~cuthbert/Library/Gregorio/examples/Populas.gabc')
        >>> #_DOCS_SHOW bsc.gregorioCommand
        >>> u'open -a"/usr/local/bin/gregorio"  ~cuthbert/Library/Gregorio/examples/Populas.gabc' #_DOCS_HIDE
        u'open -a"/usr/local/bin/gregorio"  ~cuthbert/Library/Gregorio/examples/Populas.gabc'
        
        
        More often, you'll want to write a textfile from writeFile:
        
        
        '''

        
        platform = common.getPlatform()
        fpApp = self.gregorioConverter
        options = self.gregorioOptions

        if platform == 'win':  # note extra set of quotes!
            cmd = '""%s" %s "%s""' % (fpApp, options, fp)
        elif platform == 'darwin':
            cmd = '%s %s %s' % (fpApp, options, fp)
        elif platform == 'nix':
            cmd = '%s %s %s' % (fpApp, options, fp)        
        self.gregorioCommand = cmd
        os.system(cmd)
        newfp = re.sub('\.gabc', '.tex', fp)
        return newfp
开发者ID:Grahack,项目名称:music21,代码行数:33,代码来源:chant.py

示例5: getTempFile

    def getTempFile(self, suffix=''):
        '''Return a file path to a temporary file with the specified suffix
        '''
        # get the root dir, which may be the user-specified dir
        rootDir = self.getRootTempDir()

        if common.getPlatform() != 'win':
            fd, fp = tempfile.mkstemp(dir=rootDir, suffix=suffix)
            if isinstance(fd, int):
                # on MacOS, fd returns an int, like 3, when this is called
                # in some context (specifically, programmatically in a 
                # TestExternal class. the fp is still valid and works
                pass
            else:
                fd.close() 
        else: # win
            if sys.hexversion < 0x02030000:
                raise EnvironmentException("Need at least Version 2.3 on Windows to create temporary files!")
            else:
                tf = tempfile.NamedTemporaryFile(dir=rootDir, suffix=suffix)
                fp = tf.name
                tf.close()

        self.printDebug([_MOD, 'temporary file:', fp])
        return fp
开发者ID:bewest,项目名称:music21-bewest.clone,代码行数:25,代码来源:environment.py

示例6: main

    def main(self, format):
        '''Create the documentation. 
        '''
        if format not in FORMATS:
            raise Exception, 'bad format'

        self.writeModuleReference()    
        self.writeGeneratedChapters()    
        self.writeContents()    

        if format == 'html':
            dirOut = self.dirBuildHtml
            pathLaunch = os.path.join(self.dirBuildHtml, 'contents.html')
        elif format == 'latex':
            dirOut = self.dirBuildLatex
            #pathLaunch = os.path.join(dirBuildHtml, 'contents.html')
        elif format == 'pdf':
            dirOut = self.dirBuildPdf
        else:
            raise Exception('undefined format %s' % format)

        if common.getPlatform() in ['darwin', 'nix', 'win']:
            # -b selects the builder
            import sphinx
            sphinxList = ['sphinx', '-E', '-b', format, '-d', self.dirBuildDoctrees,
                         self.dirRst, dirOut] 
            sphinx.main(sphinxList)
    
        if format == 'html':
            webbrowser.open(pathLaunch)
开发者ID:knuton,项目名称:music21,代码行数:30,代码来源:build.py

示例7: launchGregorio

    def launchGregorio(self, fp=None):
        """
        converts a .gabc file to LaTeX using the
        gregorio converter.  Returns the filename with .tex substituted for .gabc
        
        >>> bsc = alpha.chant.BaseScoreConverter()
        >>> fn = '~cuthbert/Library/Gregorio/examples/Populas.gabc'
        >>> #_DOCS_SHOW newFp = bsc.launchGregorio(fn)
        >>> #_DOCS_SHOW bsc.gregorioCommand
        >>> 'open -a"/usr/local/bin/gregorio" ' + fn #_DOCS_HIDE
        'open -a"/usr/local/bin/gregorio"  ~cuthbert/Library/Gregorio/examples/Populas.gabc'
        
        
        More often, you'll want to write a textfile from writeFile:
        
        """
        platform = common.getPlatform()
        fpApp = self.gregorioConverter
        options = self.gregorioOptions

        if platform == "win":  # note extra set of quotes!
            cmd = '""%s" %s "%s""' % (fpApp, options, fp)
        elif platform == "darwin":
            cmd = "%s %s %s" % (fpApp, options, fp)
        elif platform == "nix":
            cmd = "%s %s %s" % (fpApp, options, fp)
        self.gregorioCommand = cmd
        os.system(cmd)
        newfp = re.sub(r"\.gabc", ".tex", fp)
        return newfp
开发者ID:chrisgreencorn,项目名称:music21,代码行数:30,代码来源:chant.py

示例8: getSettingsPath

 def getSettingsPath(self):
     platform = common.getPlatform()
     if platform == 'win':
         # try to use defined app data directory for preference file
         # this is not available on all windows versions
         if 'APPDATA' in os.environ:
             directory = os.environ['APPDATA']
         elif ('USERPROFILE' in os.environ and
             os.path.exists(os.path.join(
                 os.environ['USERPROFILE'], 'Application Data'))):
             directory = os.path.join(
                 os.environ['USERPROFILE'],
                 'Application Data',
                 )
         else:  # use home directory
             directory = os.path.expanduser('~')
         return os.path.join(directory, 'music21-settings.xml')
     elif platform in ['nix', 'darwin']:
         # alt : os.path.expanduser('~')
         # might not exist if running as nobody in a webserver...
         if 'HOME' in os.environ:
             directory = os.environ['HOME']
         else:
             directory = '/tmp/'
         return os.path.join(directory, '.music21rc')
开发者ID:TimRichter,项目名称:music21,代码行数:25,代码来源:environment.py

示例9: launch

    def launch(self, filePath, fmt=None, options='', app=None, key=None):
        '''
        Opens the appropriate viewer for the file generated by .write()
        '''
        if fmt is None and self.registerShowFormats:
            fmt = self.registerShowFormats[0]    
        if app is None:
            if key is not None:
                app = environLocal._ref[key]
            elif self.launchKey is not None:
                app = environLocal._ref[self.launchKey]
            else:
                app = environLocal.formatToApp(fmt)

        platform = common.getPlatform()
        if app is None:
            if platform == 'win':
                # no need to specify application here:
                # windows starts the program based on the file extension
                cmd = 'start %s' % (filePath)
            elif platform == 'darwin':
                cmd = 'open %s %s' % (options, filePath)
            else:
                raise SubConverterException(
                    "Cannot find a valid application path for format {}. "
                    "Specify this in your Environment by calling "
                    "environment.set({!r}, 'pathToApplication')".format(
                        self.registerFormats[0], self.launchKey))
        elif platform == 'win':  # note extra set of quotes!
            cmd = '""%s" %s "%s""' % (app, options, filePath)
        elif platform == 'darwin':
            cmd = 'open -a"%s" %s %s' % (app, options, filePath)
        elif platform == 'nix':
            cmd = '%s %s %s' % (app, options, filePath)
        os.system(cmd)
开发者ID:jamesgoodsell,项目名称:music21,代码行数:35,代码来源:subConverters.py

示例10: launch

    def launch(self, fmt, fp, options='', app=None):
        # see common.fileExtensions for format names 
        format, ext = common.findFormat(fmt)
        if format == 'lilypond':
            environmentKey = 'lilypondPath'
        elif format in ['png', 'jpeg']:
            environmentKey = 'graphicsPath'
        elif format in ['svg']:
            environmentKey = 'vectorPath'
        elif format in ['pdf']:
            environmentKey = 'pdfPath'
        elif format == 'musicxml':
            environmentKey = 'musicxmlPath'
        elif format == 'midi':
            environmentKey = 'midiPath'
        elif format == 'vexflow':
            try:
                import webbrowser
                if fp.find('\\') != -1:
                    pass
                else:
                    if fp.startswith('/'):
                        fp = 'file://' + fp
                
                webbrowser.open(fp)
                return
            except:
                print "Cannot open webbrowser, sorry.  go to file://%s" % fp
        else:
            environmentKey = None
            fpApp = None

        if environmentKey is not None:
            fpApp = self._ref[environmentKey]

        # substitute app provided via argument
        if app is not None:
            fpApp = app 

        platform = common.getPlatform()
        if fpApp is None and platform not in ['win', 'darwin']:
            raise EnvironmentException("Cannot find a valid application path for format %s. Specify this in your Environment by calling environment.set(%r, 'pathToApplication')" % (format, environmentKey))
        
        if platform == 'win' and fpApp is None:
            # no need to specify application here: windows starts the program based on the file extension
            cmd = 'start %s' % (fp)
        elif platform == 'win':  # note extra set of quotes!
            cmd = '""%s" %s "%s""' % (fpApp, options, fp)
        elif platform == 'darwin' and fpApp is None:
            cmd = 'open %s %s' % (options, fp)
        elif platform == 'darwin':
            cmd = 'open -a"%s" %s %s' % (fpApp, options, fp)
        elif platform == 'nix':
            cmd = '%s %s %s' % (fpApp, options, fp)
        os.system(cmd)
开发者ID:msampaio,项目名称:music21,代码行数:55,代码来源:environment.py

示例11: _loadDefaults

    def _loadDefaults(self, forcePlatform=None):
        '''Load defaults. All keys are derived from these defaults.
        '''
        self._ref['directoryScratch'] = None # path to a directory for temporary files
        self._ref['lilypondPath'] = None # path to lilypond
        self._ref['lilypondVersion'] = None # version of lilypond
        self._ref['lilypondFormat'] = 'pdf' 
        self._ref['lilypondBackend'] = 'ps' 
        # path to a MusicXML reader: default, will find "Finale Notepad"
        self._ref['musicxmlPath'] = None 
        self._ref['midiPath'] = None # path to a midi reader
        self._ref['graphicsPath'] = None # path to a graphics viewer
        self._ref['vectorPath'] = None # path to a vector graphics viewer
        self._ref['pdfPath'] = None # path to a pdf viewer

        # path to MuseScore (if not the musicxmlPath...) for direct creation of PNG from MusicXML
        self._ref['musescoreDirectPNGPath'] = None
        self._ref['showFormat'] = 'musicxml' 
        self._ref['writeFormat'] = 'musicxml' 
        self._ref['autoDownload'] = 'ask' 
        self._ref['debug'] = 0
        # printing of missing import warnings
        self._ref['warnings'] = 1 # default/non-zero is on

        # store a list of strings
        self._ref['localCorpusSettings'] = [] 

        if forcePlatform is None:
            platform = common.getPlatform()
        else:
            platform = forcePlatform

        if platform == 'win':
            for name, value in [
                ('lilypondPath', 'lilypond'),
                ]:
                self.__setitem__(name, value) # use for key checking
        elif platform == 'nix':
            for name, value in [('lilypondPath', 'lilypond')]:
                self.__setitem__(name, value) # use for key checking
        elif platform ==  'darwin':
            for name, value in [
            ('lilypondPath', '/Applications/Lilypond.app/Contents/Resources/bin/lilypond'),
            ('musicxmlPath', '/Applications/Finale Notepad 2012.app'),
            ('graphicsPath', '/Applications/Preview.app'),
            ('vectorPath', '/Applications/Preview.app'),
            ('pdfPath', '/Applications/Preview.app'),
            ('midiPath', '/Applications/QuickTime Player.app'),
            ('musescoreDirectPNGPath', '/Applications/MuseScore.app/Contents/MacOS/mscore'),
                ]:
                self.__setitem__(name, value) # use for key checking
开发者ID:GenosResearchGroup,项目名称:music21-old,代码行数:51,代码来源:environment.py

示例12: launch

    def launch(self, fmt, fp, options='', app=None):
        '''
        Opens a file with an either default or user-specified applications.
        
        OMIT_FROM_DOCS

        Optionally, can add additional command to erase files, if necessary 
        Erase could be called from os or command-line arguments after opening
        the file and then a short time delay.

        TODO: Move showImageDirectfrom lilyString.py ; add MIDI
        TODO: Switch to module subprocess to prevent hanging.
        '''
        # see common.fileExtensions for format names 
        format, ext = common.findFormat(fmt)
        if format == 'lilypond':
            fpApp = self.ref['lilypondPath']
        elif format in ['png', 'jpeg']:
            fpApp = self.ref['graphicsPath']   
        elif format in ['pdf']:
            fpApp = self.ref['pdfPath']   
        elif format == 'musicxml':
            fpApp = self.ref['musicxmlPath']   
        elif format == 'midi':
            fpApp = self.ref['midiPath']   
        else:
            fpApp = None

        # substitute provided app
        if app != None:
            fpApp = app 

        platform = common.getPlatform()
        if fpApp is None and platform != 'win':
            raise EnvironmentException("Cannot find an application for format %s, specify this in your environment" % fmt)
        
        if platform == 'win' and fpApp is None:
            # no need to specify application here: windows starts the program based on the file extension
            cmd = 'start %s' % (fp)
        elif platform == 'win':  # note extra set of quotes!
            cmd = '""%s" %s "%s""' % (fpApp, options, fp)
        elif platform == 'darwin':
            cmd = 'open -a"%s" %s %s' % (fpApp, options, fp)
        elif platform == 'nix':
            cmd = '%s %s %s' % (fpApp, options, fp)
        print cmd
        os.system(cmd)
开发者ID:bewest,项目名称:music21-bewest.clone,代码行数:47,代码来源:environment.py

示例13: getSettingsPath

 def getSettingsPath(self):
     '''Return the path to the platform specific settings file.
     '''
     platform = common.getPlatform()
     if platform == 'win':
         # try to use defined app data directory for preference file
         # this is not available on all windows versions
         if 'APPDATA' in os.environ.keys():
             dir = os.environ['APPDATA']
         elif ('USERPROFILE' in os.environ.keys() and
             os.path.exists(os.path.join(
             os.environ['USERPROFILE'], 'Application Data'))):
             dir = os.path.join(os.environ['USERPROFILE'], 
                                'Application Data')
         else: # use home directory
             dir = os.path.expanduser('~')       
         return os.path.join(dir, 'music21-settings.xml')
     elif platform in ['nix', 'darwin']:
         # alt : os.path.expanduser('~') 
         dir = os.environ['HOME']
         return os.path.join(dir, '.music21rc')
开发者ID:bewest,项目名称:music21-bewest.clone,代码行数:21,代码来源:environment.py

示例14: launchLaTeX

    def launchLaTeX(self, fp = None):
        '''
        converts a .tex file to pdf using lulatex
        Returns the filename with .pdf substituted for .tex
        '''
        platform = common.getPlatform()
        fpApp = self.latexConverter
        options = self.latexOptions
        fpDir = os.path.dirname(fp)
        options += ' --output-dir="' + fpDir + '"'

        if platform == 'win':  # note extra set of quotes!
            cmd = '""%s" %s "%s""' % (fpApp, options, fp)
        elif platform == 'darwin':
            cmd = '%s %s %s' % (fpApp, options, fp)
        elif platform == 'nix':
            cmd = '%s %s %s' % (fpApp, options, fp)        
        self.gregorioCommand = cmd
        os.system(cmd)
        newfp = re.sub(r'\.tex', '.pdf', fp)
        return newfp
开发者ID:Wajih-O,项目名称:music21,代码行数:21,代码来源:chant.py

示例15: getSettingsPath

 def getSettingsPath(self):
     platform = common.getPlatform()
     if platform == "win":
         # try to use defined app data directory for preference file
         # this is not available on all windows versions
         if "APPDATA" in os.environ:
             directory = os.environ["APPDATA"]
         elif "USERPROFILE" in os.environ and os.path.exists(
             os.path.join(os.environ["USERPROFILE"], "Application Data")
         ):
             directory = os.path.join(os.environ["USERPROFILE"], "Application Data")
         else:  # use home directory
             directory = os.path.expanduser("~")
         return os.path.join(directory, "music21-settings.xml")
     elif platform in ["nix", "darwin"]:
         # alt : os.path.expanduser('~')
         # might not exist if running as nobody in a webserver...
         if "HOME" in os.environ:
             directory = os.environ["HOME"]
         else:
             directory = "/tmp/"
         return os.path.join(directory, ".music21rc")
开发者ID:EQ4,项目名称:music21,代码行数:22,代码来源:environment.py


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