Ejemplo n.º 1
0
 def cleanup_exit(*args, **kwargs):
     print("\nBye!")
     Program.stop()
     s.disable()
     w.disable()
     m.disable()
     WebSocketBase.stop_reactor()
     exit()
Ejemplo n.º 2
0
def item_chosen(choice, button):
    body = [urwid.Divider("-"), urwid.Text(choice, align='center'), urwid.Divider("-"), urwid.Text("Parameters:")]

    params = {}
    for p, v in Program.getPromotedPrograms()[choice].getParams().items():
        #body.append(urwid.Text())
        edit = urwid.Edit(caption = u"▸ " + p.title() + ": ", edit_text = v)
        body.append(urwid.AttrMap(edit, None, focus_map='reversed'))
        #body.append(urwid.Divider())
        params[p] = edit

    body.append(urwid.Divider("-"))

    ok = urwid.Button(u'Ok')
    back = urwid.Button(u'Back')
    
    urwid.connect_signal(ok, 'click', start_program, user_args = [choice, params])
    urwid.connect_signal(back, 'click', show_menu)
    
    tOk = urwid.AttrMap(ok, None, focus_map='reversed')
    
    body.append(tOk)
    body.append(urwid.AttrMap(back, None, focus_map='reversed'))

    mainWidget.original_widget = urwid.Filler(urwid.Pile(body, focus_item=tOk))
Ejemplo n.º 3
0
    def setFile(self, fileName):
        """The method setFile removes the old file and puts the new file in place with the preferred name of a file.
        :param fileName: The name of the new file
        :type fileName: Str. -- path to the new file
        
        """

        self.fileName = self.getPreferredFileName()
        Program.Program().execute("mv " + fileName + " " + self.fileName, "mv",
                                  self)
Ejemplo n.º 4
0
def start_program(choice, params, button):
    cParams = {}
    for p in params:
        cParams[p] = params[p].get_edit_text()

    if Program.running:
        Program.running.stop()
        Program.running.join()

    p = Program.getPromotedPrograms()[choice](**cParams)
    p.start()
    show_menu()
Ejemplo n.º 5
0
 def from_xml_(self, xml_string):
     recording = parseString(xml_string.encode(XMLDOC_CODEPAGE))
     try:
         self.id_ = str(recording.getElementsByTagName(RECORDING_ID_NODE)[0].firstChild.data)
         self.schedule_id_ = str(recording.getElementsByTagName(RECORDING_SCHEDULE_ID_NODE)[0].firstChild.data)
         self.channel_id_ = str(recording.getElementsByTagName(RECORDING_CHANNEL_ID_NODE)[0].firstChild.data)
     except:
         return False        
     try:
         self.is_active_ = string_to_bool(recording.getElementsByTagName(RECORDING_IS_ACTIVE_NODE)[0].firstChild.data)
     except:
         self.is_active_ = False
     try:
         self.is_conflicting_ = string_to_bool(recording.getElementsByTagName(RECORDING_IS_CONFLICT_NODE)[0].firstChild.data)
     except:
         self.is_conflicting_ = False
     try:
         self.program_ = Program(recording.toxml())
     except:
         self.program_ = None
     return True
Ejemplo n.º 6
0
 def from_xml_(self, xml_string):
     schedule = parseString(xml_string.encode(XMLDOC_CODEPAGE))
     try:
         self.channel_id_ = str(
             schedule.getElementsByTagName(SCHEDULE_CHANNEL_ID_NODE)
             [0].firstChild.data)
         self.program_id_ = str(
             schedule.getElementsByTagName(SCHEDULE_PROGRAM_ID_NODE)
             [0].firstChild.data)
         self.program_ = Program(
             schedule.getElementsByTagName(EPG_PROGRAM)[0].toxml())
     except:
         return False
     try:
         self.is_repeat_ = string_to_bool(
             schedule.getElementsByTagName(SCHEDULE_REPEATE_NODE)
             [0].firstChild.data)
     except:
         self.is_repeat_ = False
     try:
         self.is_new_only_ = string_to_bool(
             schedule.getElementsByTagName(SCHEDULE_NEW_ONLY_NODE)
             [0].firstChild.data)
     except:
         self.is_new_only_ = False
     try:
         self.is_record_series_anytime_ = string_to_bool(
             schedule.getElementsByTagName(SCHEDULE_SERIES_ANYTIME_NODE)
             [0].firstChild.data)
     except:
         self.is_record_series_anytime_ = False
     try:
         self.recordings_to_keep_ = int(
             schedule.getElementsByTagName(SCHEDULE_REC_TO_KEEP_NODE)
             [0].firstChild.data)
     except:
         self.recordings_to_keep_ = 0
Ejemplo n.º 7
0
 def get_params():
     return Program.get_params()
Ejemplo n.º 8
0
 def start_program(self, **info):
     Program.start(**info)
Ejemplo n.º 9
0
 def get_params():
     params = Program.get_params()
     params["uri"] = "http://spartan.ac.brocku.ca/~tmulligan/3p82inv_hand.html"
     params["refresh_duration"] = "20"
     return params
Ejemplo n.º 10
0
 def __init__(self, uri_websocket):
     Program.__init__(self)
     self.uri_websocket = uri_websocket
Ejemplo n.º 11
0
 def get_params():
     params = Program.get_params()
     params['text'] = u"0123456789abcdefghijklmnopqrstuvwxyzäöüß?!.,-\'\""
     params['slide_speed'] = "0.4"
     return params
Ejemplo n.º 12
0
 def __init__(self, color=None, text=None, slide_speed=None):
     Program.__init__(self, color=color)
     self.text = self.get_params()["text"] if text is None else unicode(text)
     self.slide_speed = float(self.get_params()["slide_speed"] if slide_speed is None else slide_speed)
Ejemplo n.º 13
0
 def get_params():
     params = Program.get_params()
     params['signs'] = "1234"
     return params
Ejemplo n.º 14
0
 def __init__(self, color=None, signs=None):
     Program.__init__(self, color=color)
     self.signs = self.get_params()["signs"] if signs is None else signs
Ejemplo n.º 15
0
 def next(self):
     self.active_switch_program = (self.active_switch_program + 1) % len(self.switch_programs)
     Program.start(**self.switch_programs[self.active_switch_program])
Ejemplo n.º 16
0
 def __init__(self, color=None, uri=None, refresh_duration=None):
     Program.__init__(self, color=color)
     self.uri = self.get_params()["uri"] if uri is None else uri
     self.refresh_duration = float(
         self.get_params()["refresh_duration"] if refresh_duration is None else refresh_duration
     )
Ejemplo n.º 17
0
    # TODO(izzy): I misunderstood the rule when I glanced at the problem.
    # We don't have th primitives for this one yet
    'b548a754.json': (ColorGridWithMask, PassGrid, (MaskFromColor, PassGrid,
                                                    Color_p(8)), Color_p(0)),
    # this one is a good exapmle of the value of for-loops, variables, and also
    # of recognizing the boarders of the grid. Notice all the repeated structure.
    'bc1d5164.json':
    (MaskedOverlay,
     (MaskedOverlay,
      (MaskedOverlay,
       (ExtractPatch, PassGrid, Int_p(0), Int_p(0), Int_p(3), Int_p(3)),
       (ExtractPatch, PassGrid, Int_p(0), Int_p(2), Int_p(3),
        Int_p(3)), (InvertMask, (MaskFromColor, (ExtractPatch, PassGrid,
                                                 Int_p(0), Int_p(2), Int_p(3),
                                                 Int_p(3)), Color_p(0)))),
      (ExtractPatch, PassGrid, Int_p(4), Int_p(0), Int_p(3), Int_p(3)),
      (InvertMask, (MaskFromColor, (ExtractPatch, PassGrid, Int_p(4), Int_p(0),
                                    Int_p(3), Int_p(3)), Color_p(0)))),
     (ExtractPatch, PassGrid, Int_p(4), Int_p(2), Int_p(3), Int_p(3)),
     (InvertMask, (MaskFromColor, (ExtractPatch, PassGrid, Int_p(4), Int_p(2),
                                   Int_p(3), Int_p(3)), Color_p(0))))
}

if __name__ == '__main__':
    for task_name in demo_programs:
        spec = demo_programs[task_name]
        P = Program(spec)
        if not P.type_check():
            print(f'The program for {task_name} failed type_check')
        print(f'{task_name}:\t{run_program_on_task_train(P, task_name)}')
Ejemplo n.º 18
0
"""
Testing 
"""

from programs import ComputerController, Computer, Program

if __name__ == "__main__":

    computer = Computer()

    computer.add_program(ComputerController(keyword='computer.umdl'))
    #computer.add_program(Program(keyword='computer_music.pmdl',callback=lambda x: print("MUSIC")))
    # computer.add_program(Program(keyword='computer_email.pmdl',callback=lambda x: print("EMAIL")))
    # computer.add_program(Program(keyword='youtube.pmdl',callback=lambda x: print("YT")))
    computer.add_program(
        Program('hey_fucker.pmdl', lambda x: print("Eres un deus")))
    computer.start_programs()
Ejemplo n.º 19
0
 def __init__(self):
     Program.__init__(self)
Ejemplo n.º 20
0
 def get_programs(self):
     programs = Program.get_promoted_programs()
     info = {}
     for p in programs:
         info[p] = programs[p].get_params()
     return info
Ejemplo n.º 21
0
 def handleConnected(self):
     print(" - Connection established!")
     print(" - Start Thread!")
     Program.raiseException = True
     self.t = Program.getPromotedPrograms()["FadeMe"](writer = self)
     self.t.start()