コード例 #1
0
ファイル: browse.py プロジェクト: shamharoth/EigenD
    def __resolve1(self, id, path, ordinal, asTerm=False):
        a = logic.render_term((tuple(path), ordinal - 1))
        r = (yield rpc.invoke_rpc(id, 'finfo', a))

        if not r.status():
            print 'rpc error, finfo'
            yield async .Coroutine.failure(*r.args(), **r.kwds())

        flist = logic.parse_clause(r.args()[0])

        if not flist:
            yield async .Coroutine.failure('no selection %d' % ordinal)

        print 'flist=', flist

        (cookie, desc, name) = flist[0][:3]
        if len(flist[0]) > 3:
            aux = flist[0][3]

        a = logic.render_term((tuple(path), cookie))
        r = (yield rpc.invoke_rpc(id, 'fideal', a))

        if not r.status():
            print 'rpc error, fideal'
            yield async .Coroutine.failure(*r.args(), **r.kwds())

        try:
            ideal = logic.parse_clause(r.args()[0], paths.make_subst(id))
        except:
            print 'cant parse:', r.args()[0]
            raise

        print 'converted', ordinal, 'to ideal', ideal
        yield async .Coroutine.success(self.__render(ideal, asTerm))
コード例 #2
0
ファイル: host_plg.py プロジェクト: jschpmn/EigenD
 def rpc_finfo(self,a):
     (path,idx) = logic.parse_clause(a)
     if len(path) == 1:
         p = self.__plugin_list.plugins_by_manufacturer.get(path[0])
         if p:
             return render_list(p,idx,lambda i,t: logic.render_term((plugin_id_escaped(t),t.name(),t.description())))
     return logic.render_term(())
コード例 #3
0
ファイル: test.py プロジェクト: tylerwood/EigenD
def runtest(kbd, clause):
    term = logic.parse_clause(clause)
    duration = int(term.args[0])
    keypresses = term.args[1:]

    libs = {}
    for i, k in enumerate(set([k.pred for k in keypresses])):
        libs[k] = i
        print 'sending lib message', i, k
        libfile = resource.find_resource('keyboard', 'testlib_%s' % k)
        if not libfile:
            print k, 'keypress not found'
            return

        writelib(kbd, i, libfile)

    seq = []
    for t in keypresses:
        assert t.args[0] > 0
        key = int(t.args[0] - 1)
        time = int(t.args[1])
        seq.append((libs[t.pred], key, time))

    print 'sending sequence len', len(seq)
    writeseq(kbd, seq)

    print 'running test'
    kbd.start_test(duration)
    print 'waiting', duration, 'ms for completion'
    return timeout.Timer(duration)
コード例 #4
0
 def doHints(self, hints):
     view, target = logic.parse_clause(hints[0])
     print 'Browser:doHints', view, target
     if view == 'browseview':
         self[8].model.change_target(target)
     else:
         print 'No hint'
コード例 #5
0
ファイル: upgrade_v0.py プロジェクト: tylerwood/EigenD
def convert_metadata(metanode):
    metadata = {}
    children = map(ord,metanode.list_children())

    adjectives = get_string(metanode,4)
    nouns = get_string(metanode,8)
    ordinal = get_number(metanode,7)
    fuzzy = get_string(metanode,12)
    relation = get_string(metanode,11)
    control = get_string(metanode,21)
    notify = get_string(metanode,22)
    master = get_string(metanode,2)
    pronoun = get_string(metanode,15)
    icon = get_string(metanode,16)

    words = adjectives.split()+nouns.split()
    notify = logic.render_termlist(logic.parse_clause(notify or '[]'))

    if words: metadata['name'] = ' '.join(words)
    if ordinal is not None: metadata['ordinal'] = ordinal
    if fuzzy: metadata['fuzzy'] = fuzzy
    if control: metadata['control'] = control
    if notify: metadata['notify'] = notify
    if master: metadata['master'] = master
    if pronoun: metadata['pronoun'] = pronoun
    if icon: metadata['icon'] = icon

    if metanode.enum_children(5)==6:
        private = get_tree(metanode.get_child(6))
        set_tree(metanode,private)
    else:
        metanode.erase()

    return metadata
コード例 #6
0
 def rpc_finfo(self, a):
     (dlist, cnum) = logic.parse_clause(a)
     all = list(
         enumerate(
             [e for k in self.__keylist() for e in self.__eventlist(k)]))
     map = tuple([(i, e.describe(), None) for (i, e) in all[cnum:]])
     return logic.render_term(map)
コード例 #7
0
 def __channels_enabled(self, v):
     channels = logic.parse_clause(v)
     self.midiprocessor.clear_enabled_channels()
     for c in channels:
         self.midiprocessor.enable_channel(c)
     self.midiprocessor.activate_enabled_channels()
     self[4][9].set_value(v)
コード例 #8
0
ファイル: scale_manager_plg.py プロジェクト: tylerwood/EigenD
 def rpc_setselected(self, arg):
     (path, name) = logic.parse_clause(arg)
     # convert name to scale
     for (n, s) in self.values:
         if n == name:
             self.__selected = s
             self.__selected_name = n
コード例 #9
0
ファイル: midi_output_plg.py プロジェクト: tylerwood/EigenD
 def rpc_fideal(self, arg):
     (path, cookie) = logic.parse_clause(arg)
     for id, n in self.__midi_port.sinks:
         if id == cookie:
             return 'ideal([~server,midiport],%s)' % logic.render_term(
                 cookie)
     return async .failure('invalid cookie')
コード例 #10
0
    def rpc_dinfo(self, a):
        path = logic.parse_clause(a)
        l = []
        l.append(('dinfo_id', self.__selected or path))

        if self.__selected:
            x = self.read_script(self.__selected)
            if x:
                (n, d, sc, rn) = x

                if rn:
                    l.append(('name', "%s (%s)" % (n, rn)))
                else:
                    l.append(('name', n))

                l.append(('', ''))

                for (i, di) in enumerate(d):
                    l.append(('description' if i == 0 else '', di))

                if self.__status:
                    l.append(('', ''))
                    l.append(('status', self.__status))

        return logic.render_term(logic.make_term('keyval', tuple(l)))
コード例 #11
0
 def rpc_resolve(self,arg):
     (a,o) = logic.parse_clause(arg)
     if a == ('current',) and o is None:
         c = self.get_value()
         if c:
             return self.__ideals(self.get_value())
     return self.__ideals()
コード例 #12
0
 def rpc_finfo(self, a):
     print 'finfo', a
     (dlist, cnum) = logic.parse_clause(a)
     # XXX
     #map = tuple([(i+cnum,e.describe(),None) for (i,e) in enumerate(self.__eventlist()[cnum:])])
     map = tuple([(e.ordinal(), e.describe(), None)
                  for (i, e) in enumerate(self.__eventlist()[cnum:])])
     return logic.render_term(map)
コード例 #13
0
 def __settrim(self,val):
     if val.is_string():
         trim = logic.parse_clause(val.as_string())
         self[5].clear_trim()
         for (cc,min,max,inv) in trim:
             self[5].set_trim(cc,min,max,inv)
         print 'trim:',trim
         self.get_private().set_data(val)
コード例 #14
0
    def rpc_cinfo(self,a):
        (path,idx) = logic.parse_clause(a)
        self.__scan()

        if len(path) == 0:
            return render_list(self.__files,idx,lambda i,t: logic.render_term((t)))

        return logic.render_term(())
コード例 #15
0
 def rpc_resolve(self,arg):
     (a,o) = logic.parse_clause(arg)
     print 'resolving virtual',arg,(a,o)
     if not a and o is None: return self.__key(*range(0,128))
     if a==('chosen',) and o is None: return self.__key(*self.choices)
     if a or o is None: return self.__key()
     o=int(o)
     if o<0 or o>127: return self.__key()
     return self.__key(o)
コード例 #16
0
ファイル: keyboard_X.py プロジェクト: shamharoth/EigenD
 def rpc_resolve(self, arg):
     (a, o) = logic.parse_clause(arg)
     print 'resolving virtual', arg, (a, o)
     if not a and o is None: return self.__key(*R(1, self.kbd_keys))
     if o is None: return self.__key()
     o = int(o)
     if a: return '[]'
     if o < 1 or o > self.kbd_keys: return self.__key()
     return self.__key(o)
コード例 #17
0
    def rpc_enumerate(self, arg):
        path = logic.parse_clause(arg)
        if len(path) > 0:
            if path[0] == factory_cat:
                return self.__enumerate_path(self.__factorydir, path[1:])
            if path[0] == user_cat:
                return self.__enumerate_path(self.__userdir, path[1:])

        return logic.render_term((0, 2))
コード例 #18
0
ファイル: finger_plg.py プロジェクト: shamharoth/EigenD
    def rpc_enumerate(self, arg):
        path = logic.parse_clause(arg)
        if len(path) > 0:
            if path[0] == factory_cat:
                return logic.render_term((len(self.__factory_fingerings), 0))
            if path[0] == user_cat:
                return logic.render_term((len(self.__user_fingerings), 0))

        return logic.render_term((0, 2))
コード例 #19
0
 def rpc_enumerate(self,a):
     path=logic.parse_clause(a)
     if len(path)==0:
         k=reduce(operator.add,[len(self.__eventlist(k)) for k in self.__keylist()],0)
         c=0
     else:
         k=0
         c=0
     return logic.render_term((k,c))
コード例 #20
0
 def upgrade_3_0_to_4_0(self, tools, address):
     root = tools.root(address)
     events = root.get_node(3)
     for e in events.iter():
         schema_node = e.get_node(255, 6)
         old_schema = schema_node.get_string()
         old_schema_term = logic.parse_clause(old_schema)
         new_schema = logic.render_term(T('schema', None, old_schema_term))
         schema_node.set_string(new_schema)
     return True
コード例 #21
0
    def rpc_finfo(self,a):
        (path,idx) = logic.parse_clause(a)

        if len(path) == 1:
            self.__scan()
            presets = self.__scanpresets(path[0])
            #return render_list(presets,idx,lambda i,t: logic.render_term((t[0],t[1],t[2],'autoload')))
            return render_list(presets,idx,lambda i,t: logic.render_term((t[0],t[1],t[2])))

        return logic.render_term(())
コード例 #22
0
 def rpc_resolve(self,arg):
     (a,o) = logic.parse_clause(arg)
     print 'resolving virtual',(a,o)
     if not a and o is None: return self.__key(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,22)
     if a==('standard',) and o is None: return self.__key(13,14,15,16,9,10,11,12,5,6,7,8,1,2,3,4)
     if a==('chosen',) and o is None: return self.__key(*self.choices)
     if a or o is None: return '[]'
     o=int(o)
     if o<1 or o>22: return '[]'
     return self.__key(o)
コード例 #23
0
ファイル: icon_manager_plg.py プロジェクト: tylerwood/EigenD
 def getIcon(self,a):
     dsc=logic.parse_clause(a)
     print 'Icon Manager getIcon: dsc=',dsc
     if os.path.splitext(dsc)[1]=='':
         dsc=dsc+'.png'
     if dsc in self.__f2p:
         uid=self.__f2p[dsc]
         print 'uid=',uid
         if os.path.exists(uid):
             return logic.render_term((dsc,files.get_ideal(logic.make_expansion('~server'),'file_sys:%s'%uid,files.FileSystemFile(uid,dsc),True))) 
コード例 #24
0
 def __size_changed(self, d):
     print '__size_changed'
     if not d.is_string():
         return False
     l = logic.parse_clause(d.as_string())
     self.__x = l[0]
     self.__y = l[1]
     self.__setup_size()
     if self.__rootFrame:
         self.__doSetSize()
コード例 #25
0
 def rpc_finfo(self, a):
     (path, idx) = logic.parse_clause(a)
     if len(path) == 1:
         p = self.__plugin_list.plugins_by_manufacturer.get(path[0])
         if p:
             return render_list(
                 p, idx, lambda i, t: logic.render_term(
                     (plugin_id_escaped(t), t.name() + ' (' + t.format()
                      + prepad_not_empty(t.category()) + ')', t.description(
                      ))))
     return logic.render_term(())
コード例 #26
0
    def upgrade_2_0_to_3_0(self,tools,address):
        root = tools.root(address)
        say = set()
        echosay = set()
        nodes = set()
        for k in root.ensure_node(3).iter():
            for t in k.iter():
                try:
                    words = t.get_node(255,6).get_data().as_string().split()
                    if words[-1]=='say':
                        echosay.add(' '.join(words))
                        say.add(' '.join(words[:-3]))
                        nodes.add(t)
                except:
                    pass

        say_seen = set()
        echosay_seen = set()
        for t in nodes:
            for e in tools.find_slaves(t.id()):
                try:
                    (es,ep) = paths.breakid_list(e)
                    en = tools.root(es).get_node(*ep)
                    er = en.get_node(255,6).get_data().as_string()
                    if not er: continue
                    c = logic.parse_clause(er)

                    # say
                    if c[1]==29:
                        phrase = ' '.join(c[3][1][0].args[0])
                        if phrase not in say:
                            print 'dangling say:',phrase
                            en.remove()
                        if phrase in say_seen:
                            print 'dup say:',phrase
                            en.remove()
                        say_seen.add(phrase)

                    # echo say
                    if c[1]==30:
                        words = c[3][1][0].args[0]
                        if words[-1]=='say':
                            phrase = ' '.join(words)
                            if phrase not in echosay:
                                print 'dangling echo say:',phrase
                                en.remove()
                            if phrase in echosay_seen:
                                print 'dup echo say:',phrase
                                en.remove()
                            echosay_seen.add(phrase)
                except:
                    utils.log_trace()

        return True
コード例 #27
0
 def rpc_fideal(self,arg):
     try:
         (path,cookie) = logic.parse_clause(arg)
         cookie=int(cookie)
     except:
         utils.log_exception()
         return async.failure('invalid cookie')
     for name,val in self.clist:
         if cookie==val:
             return 'cmp([dsc(~(parent)"#2",%d)])' % val
     return async.failure('invalid cookie')
コード例 #28
0
ファイル: scale_manager_plg.py プロジェクト: tylerwood/EigenD
    def rpc_resolve(self, a):
        (a, o) = logic.parse_clause(a)

        if a or not o:
            return '[]'

        o = int(o) - 1
        if o >= 0 and o < len(self.values):
            return '[%s]' % self.__ideal(o)

        return '[]'
コード例 #29
0
    def rpc_enumerate(self,a):
        path = logic.parse_clause(a)
        self.__scan()

        if len(path) == 0:
            return logic.render_term((0, len(self.__f2p)))

        if len(path) == 1:
            p = self.__scanpresets(path[0])
            return logic.render_term((len(p), 0))

        return logic.render_term((0,0))
コード例 #30
0
ファイル: convolver_plg.py プロジェクト: tylerwood/EigenD
    def rpc_finfo(self, a):
        (path, idx) = logic.parse_clause(a)
        self.__scan()

        if len(path) == 0:
            # list of tuples for the browser window, [(cookie,textcolumn1,textcolumn2),...]
            map = tuple([(files, files, self.__c2n.get(files))
                         for files in self.__files[idx:]])
            mapstr = logic.render_term(map)
            return mapstr

        return logic.render_term(())