Ejemplo n.º 1
0
def evaluate(inp, client, l, DBlocation):
    inp = inp.split(' ')
    status = client.status()

    if len(inp) > 1 and not str(inp[1]):
        inp.pop()

    if inp[0] == 'p' or 'play' == (inp[0]):
        try:
            if not status['state'] == 'stop':
                if len(inp) == 1:
                    util.pause(client)
                else:
                    util.play(client, int(inp[1]))
            else:
                if len(inp) == 1:
                    util.play(client, 0)
                else:
                    util.play(client, int(inp[1]))
        except:
            print('mpd error: bad song index')
    elif inp[0] == 'pause':
        util.pause(client)
    elif inp[0] == 'next' or inp[0] == 'n':
        util.next(client)
    elif inp[0] == 'previous' or inp[0] == 'ps':
        util.previous(client)
    elif inp[0] == 'stop':
        util.stop(client)
    elif inp[0] == 'pl' or inp[0] == 'playlist':
        util.print_playlist(client)
    elif inp[0] == 'update' or inp[0] == 'u':
        util.update(client)
    elif inp[0] == 'clear':
        util.clear(client)
    elif inp[0] == 'random':
        util.mpdrandom(client, inp[1])
    elif inp[0] == 'shuffle':
        util.shuffle(client)
    elif inp[0] == 'consume':
        util.consume(client, inp[1])
    elif inp[0] == 'swap':
        util.swap(client, int(inp[1]) - 1, int(inp[2]) - 1)
    elif inp[0] == 'single':
        util.single(client, inp[1])
    elif inp[0] == 'search' or inp[0] == 's':
        if '-f' in inp or '--filter' in inp:
            l = util.mpdsearch(inp[1], inp, DBlocation, True)
        else:
            l = util.mpdsearch(inp[1], inp, DBlocation, False)
    elif inp[0] == 'a' or inp[0] == 'add':
        if l:
            for line in l:
                client.add(line)
        else:
            print('You have to search first!')
    elif inp[0] == 'q' or inp[0] == 'quit':
        quit()
    return l
Ejemplo n.º 2
0
 def rt_equiv(self, obj):
     if not UT.is_satisfies(RT.Sequential, obj):
         return false
     ms = UT.seq(obj)
     s = UT.seq(self)
     while s is not nil:
         if ms is nil or UT.equiv(UT.first(s), UT.first(ms)) is false:
             return false
         ms = UT.next(ms)
         s = UT.next(s)
     return true if ms is nil else false
Ejemplo n.º 3
0
 def rt_equiv(self, obj):
     if not UT.is_satisfies(RT.Sequential, obj):
         return false
     ms = UT.seq(obj)
     s = UT.seq(self)
     while s is not nil:
         if ms is nil or UT.equiv(UT.first(s), UT.first(ms)) is false:
             return false
         ms = UT.next(ms)
         s = UT.next(s)
     return true if ms is nil else false
Ejemplo n.º 4
0
    def rt_equiv(self, other):
        if UT.is_satisfies(RT.IPersistentVector, other):
            if UT.equiv(RT.count.invoke1(self), UT.count(other)) is false:
                return false
            for x in range(self._cnt):
                i = wrap_int(x)
                if RT.equiv(RT.nth.invoke1(self, i), UT.nth(self, i)) is false:
                    return false
            return true
        else:
            if RT.is_satisfies.invoke1(RT.Sequential, other) is false:
                return false
            ms = RT.seq.invoke1(other)

            for x in range(self._cnt):

                if ms is nil or UT.equiv(UT.nth(x, wrap_int(x)),
                                         UT.first(ms)) is false:
                    return false

                ms = UT.next(ms)

            if ms is not nil:
                return false

        return true
Ejemplo n.º 5
0
def process():
    global callback, database, timer

    # now
    now = datetime.now()
    (c, n) = util.next(now, database)

    current_prediction_time = c
    current_prediction_value = database[c]
    next_predition_time = n
    next_predition_value = database[n]

    if callback:
        callback((current_prediction_value, current_prediction_time,
                  next_predition_value, next_predition_time))

    sleep_dt = next_predition_time - now

    # print "&&&&&&&&&&&&&&&&&&&&&&&&"
    # print current_prediction_time
    # print current_prediction_value
    # print "-----"
    # print now
    # print next_predition_time
    # print "sleep for: "
    # print next_predition_time - now

    # time.sleep(sleep_dt.total_seconds())

    timer = threading.Timer(sleep_dt.total_seconds(), process)
    timer.start()
Ejemplo n.º 6
0
    def rt_equiv(self, other):
        if UT.is_satisfies(RT.IPersistentVector, other):
            if UT.equiv(RT.count.invoke1(self), UT.count(other)) is false:
                return false
            for x in range(self._cnt):
                i = wrap_int(x)
                if RT.equiv(RT.nth.invoke1(self, i), UT.nth(self, i)) is false:
                    return false
            return true
        else:
            if RT.is_satisfies.invoke1(RT.Sequential, other) is false:
                return false
            ms = RT.seq.invoke1(other)

            for x in range(self._cnt):

                if ms is nil or UT.equiv(UT.nth(x, wrap_int(x)), UT.first(ms)) is false:
                    return false


                ms = UT.next(ms)

            if ms is not nil:
                return false

        return true