コード例 #1
0
def launchIdle():
    # flag for athenacl to now its an idle session
    # passing -s, 'terminal' here does not work...
    # this will cal this same module again, but under idle, w/ terminal session
    sys.argv = [
        'python',
        '-t',
        'athenacl via IDLE',
        '-c',
        'import athenaCL.athenacl',
    ]  # force threads off
    # attribute error is rause when idle quits by closing window mid proc
    # cant avoid by catching error; traceback start in the framework
    try:
        import idle
    except ImportError:
        idlePath = osTools.findIdle()
        if idlePath == None:
            dialog.msgOut('idle cannot be found\n')
            return None
        sys.path.append(idlePath)
        dialog.msgOut('launching idle from:\n%s\n' % idlePath)
        try:
            import idle
        except (ImportError, AttributeError):
            return None
    except AttributeError:  # happens on session interrupt
        return None
コード例 #2
0
ファイル: multiset.py プロジェクト: gmkling/athenacl
 def _getCount(self, termObj):
     """get number of pitches to read interactively"""
     query = 'number of pitches?'
     while 1:
         usrStr = dialog.askStr(query, termObj)
         if usrStr == None: return None
         num = drawer.strToNum(usrStr, 'int')
         if num != None and num != 0: return num
         else:
             dialog.msgOut(('%senter a positive or negative integer.\n' % 
                 lang.TAB), termObj)          
コード例 #3
0
ファイル: multiset.py プロジェクト: tjingboem/athenaCL
def getPitch(termObj=None, read=None):
    while 1:
        if read != None:
            usrStr = read
        else:
            usrStr = dialog.askStr("enter a pitch or note name:", termObj)
            if usrStr == None:
                return None
        usrStr = usrStr.lower()  # make sure lower case
        try:
            obj = pitchTools.Pitch(usrStr)
        except error.PitchSyntaxError:
            if read != None:
                return None  # failure
            dialog.msgOut('%sno such pitch exists.\n' % lang.TAB, termObj)
            continue
        return obj
コード例 #4
0
ファイル: multiset.py プロジェクト: ericahub/athenacl
def getPitch(termObj=None, read=None):
    while 1:
        if read != None:
            usrStr = read
        else:
            usrStr = dialog.askStr("enter a pitch or note name:", termObj)
            if usrStr == None:
                return None
        usrStr = usrStr.lower() # make sure lower case
        try:
            obj = pitchTools.Pitch(usrStr)
        except error.PitchSyntaxError: 
            if read != None:    
                return None # failure
            dialog.msgOut('%sno such pitch exists.\n' % lang.TAB, termObj)
            continue
        return obj
コード例 #5
0
ファイル: athenacl.py プロジェクト: ericahub/athenacl
def launchIdle():
    # flag for athenacl to now its an idle session
    # passing -s, 'terminal' here does not work...
    # this will cal this same module again, but under idle, w/ terminal session
    sys.argv = ['python', '-t', 'athenacl via IDLE', 
                    '-c', 'import athenaCL.athenacl',] # force threads off
    # attribute error is rause when idle quits by closing window mid proc
    # cant avoid by catching error; traceback start in the framework
    try:
        import idle
    except ImportError:
        idlePath = osTools.findIdle()
        if idlePath == None:
            dialog.msgOut('idle cannot be found\n')
            return None
        sys.path.append(idlePath)
        dialog.msgOut('launching idle from:\n%s\n' % idlePath)
        try:
            import idle
        except (ImportError, AttributeError):
            return None
    except AttributeError: # happens on session interrupt
        return None
コード例 #6
0
ファイル: athenacl.py プロジェクト: ericahub/athenacl
# parse args
for argPair in parsedArgs:
    # only terminal and idle can be launched interactively
    if argPair[0] == '-s':
        if argPair[1] != None:
            option = argPair[1]
            if option in ['terminal', 'idle', 'cgi']: # cgi just for test
                sessionType = option
            else: sessionType = None # get default
    elif argPair[0] == '-e': 
        if cmdList == None: cmdList = []
        cmdList.append(argPair[1])
    elif argPair[0]  in ['-q', '--quiet']: 
        verbose = 0 # 2 is no output
    elif argPair[0] in ['-v', '--version']:
        dialog.msgOut(('%s\n' % athVersionStr))
        exit = 1 # exit after getting info
    elif argPair[0] in ['-h', '--help']:
        dialog.msgOut(helpMsg(athVersionStr, flagsRef))
        exit = 1 # exit after print help
        
if exit: 
    sys.exit() # help, version, exit after command function

# command flag over-rides
if IDLE_ACTIVE: # regardless of platform, always force these options
    sessionType = 'terminal' # session shold look like a terminal
else: # idle not active, get default session if not set
    if os.name == 'posix':
        if sessionType == None: sessionType = 'terminal'
    else: # all win plats
コード例 #7
0
ファイル: multiset.py プロジェクト: tjingboem/athenaCL
    def _makeObj(self, ao=None, read=None):
        """ returns sc, pcset, trans from 0=C, and inv
        read arg allows non-interactive use: provide data as arg
        can be used to replace calls to getSet
        pass an ao to get references and termObj
        """
        if ao != None:
            termObj = ao.termObj
            dlgVisMet = ao.external.getPref('athena', 'dlgVisualMethod')
            fpLastDir = ao.aoInfo['fpLastDir']
        else:  # get defaults
            termObj = None
            dlgVisMet = 'txt'
            fpLastDir = ''

        attempts = 0
        usrStrType = None  # not yet known what format user provided
        while 1:
            if read != None:  # method must return result, not interactive
                if attempts > 0:
                    return None  # dont run more than once when reading
                usrStr = read  # assign to usrStr for parsing
            else:
                usrStr = dialog.askStr(lang.msgSCgetSet, termObj)
                if usrStr == None: return None
            attempts = attempts + 1
            usrStrType = self._parseSetInputType(usrStr, termObj)
            # may get one or the other of these as input values
            scFound = None
            psSet = None
            try:
                if usrStrType == 'forte':
                    scFound = self._parseForte(usrStr)
                elif usrStrType == 'psName':
                    psSet = self._parsePsName(usrStr)
                elif usrStrType == 'psReal':
                    psSet = self._parsePsReal(usrStr)
                elif usrStrType == 'sieve':
                    psSet = self._parseSieve(usrStr)
                elif usrStrType == 'midi':
                    psSet = self._parseMidi(usrStr)
                elif usrStrType == 'fq':
                    psSet = self._parseFq(usrStr)
                elif usrStrType == 'txt':
                    psSet = self._parseTxt(usrStr)
                # import will get a file dialog
                elif usrStrType == 'import':
                    msg, ok = dialog.promptGetFile(lang.msgSCgetAudacity,
                                                   fpLastDir, 'file',
                                                   dlgVisMet, termObj)
                    count = self._getCount(
                        termObj)  # count may be equal to None
                    # call parse text after getting file path
                    if ok: psSet = self._parseTxt(msg, count)
                    else: return None  # cancel
                else: return None
            except error.MultisetError:
                dialog.msgOut(lang.msgSCnoSuchSet, termObj)
                continue
            try:
                obj = Multiset(psSet, scFound)
            except error.MultisetError:
                return None  # will be understood as error

            if read == None:  # dont check response
                sc = obj.repr('sc')
                ps = obj.repr('psName')
                query = lang.TAB + 'SC %s as %s? ' % (sc, ps)
                ok = dialog.askYesNoCancel(query, 1, termObj)
                if ok != -1 and ok != 1: continue  # return to top
                elif ok == -1: return None  # destroy obj
            return obj
コード例 #8
0
ファイル: multiset.py プロジェクト: ericahub/athenacl
    def _makeObj(self, ao=None, read=None):
        """ returns sc, pcset, trans from 0=C, and inv
        read arg allows non-interactive use: provide data as arg
        can be used to replace calls to getSet
        pass an ao to get references and termObj
        """
        if ao != None:
            termObj = ao.termObj
            dlgVisMet = ao.external.getPref('athena', 'dlgVisualMethod')
            fpLastDir = ao.aoInfo['fpLastDir']
        else: # get defaults
            termObj = None
            dlgVisMet = 'txt'
            fpLastDir = ''
        
        attempts = 0
        usrStrType = None # not yet known what format user provided
        while 1:
            if read != None: # method must return result, not interactive
                if attempts > 0: return None # dont run more than once when reading
                usrStr = read # assign to usrStr for parsing
            else:
                usrStr = dialog.askStr(lang.msgSCgetSet, termObj)
                if usrStr == None: return None
            attempts = attempts + 1
            usrStrType = self._parseSetInputType(usrStr, termObj)
            # may get one or the other of these as input values
            scFound = None
            psSet = None
            try:
                if usrStrType == 'forte':
                    scFound = self._parseForte(usrStr)
                elif usrStrType == 'psName':
                    psSet = self._parsePsName(usrStr)
                elif usrStrType == 'psReal':
                    psSet = self._parsePsReal(usrStr)
                elif usrStrType == 'sieve':
                    psSet = self._parseSieve(usrStr)
                elif usrStrType == 'midi':
                    psSet = self._parseMidi(usrStr)
                elif usrStrType == 'fq':
                    psSet = self._parseFq(usrStr)
                elif usrStrType == 'txt':
                    psSet = self._parseTxt(usrStr)
                # import will get a file dialog
                elif usrStrType == 'import':
                    msg, ok = dialog.promptGetFile(lang.msgSCgetAudacity, 
                                             fpLastDir, 'file', dlgVisMet, termObj)
                    count = self._getCount(termObj) # count may be equal to None
                    # call parse text after getting file path
                    if ok: psSet = self._parseTxt(msg, count)
                    else: return None # cancel
                else: return None
            except error.MultisetError:
                dialog.msgOut(lang.msgSCnoSuchSet, termObj)
                continue
            try:
                obj = Multiset(psSet, scFound)
            except error.MultisetError:
                return None # will be understood as error

            if read == None: # dont check response
                sc = obj.repr('sc')
                ps = obj.repr('psName')
                query = lang.TAB + 'SC %s as %s? ' % (sc, ps)
                ok = dialog.askYesNoCancel(query, 1, termObj)               
                if ok != -1 and ok != 1:  continue  # return to top
                elif ok == -1: return None # destroy obj    
            return obj
コード例 #9
0
for argPair in parsedArgs:
    # only terminal and idle can be launched interactively
    if argPair[0] == '-s':
        if argPair[1] != None:
            option = argPair[1]
            if option in ['terminal', 'idle', 'cgi']:  # cgi just for test
                sessionType = option
            else:
                sessionType = None  # get default
    elif argPair[0] == '-e':
        if cmdList == None: cmdList = []
        cmdList.append(argPair[1])
    elif argPair[0] in ['-q', '--quiet']:
        verbose = 0  # 2 is no output
    elif argPair[0] in ['-v', '--version']:
        dialog.msgOut(('%s\n' % athVersionStr))
        exit = 1  # exit after getting info
    elif argPair[0] in ['-h', '--help']:
        dialog.msgOut(helpMsg(athVersionStr, flagsRef))
        exit = 1  # exit after print help

if exit:
    sys.exit()  # help, version, exit after command function

# command flag over-rides
if IDLE_ACTIVE:  # regardless of platform, always force these options
    sessionType = 'terminal'  # session shold look like a terminal
else:  # idle not active, get default session if not set
    if os.name == 'posix':
        if sessionType == None: sessionType = 'terminal'
    else:  # all win plats