Example #1
1
 def set_leds(self, red, green, blue, white):
     print "turned off:", self.turned_off
     App.get_running_app().do_color_change \
         ( self.send_coap
         , self.idx
         , red, green, blue, white, self.status
         )
Example #2
0
    def build(self):

        self.settings_cls = SettingsWithSidebar

        game = PlanetGame(do_rotation=False,do_translation=False)
        # Settings come in as unicode!
        sunmass = float(App.get_running_app().config.get('planetapp','defaultsunmass'))
        game.sunmass = sunmass
        game.gravity = float(App.get_running_app().config.get('planetapp','gravity'))
        game.planetmass = float(App.get_running_app().config.get('planetapp','planetmass'))
        game.resetmass = float(App.get_running_app().config.get('planetapp','resetmass'))

        game.add_planet(True, (100,100), (0,0), sunmass, 10, (1,1,1))
        
        Clock.schedule_interval(game.update, 1.0 / 120.0)

        self.root = PlanetGameLayout()
        self.root.add_widget(game)
        

        b = Button(text="Reset",size_hint=(.3,.05),pos_hint={'x':.7,'y':0})
        b.bind(on_press=self.root.clear_planets)
        self.root.add_widget(b)
        b2 = SettingsButton(text="Settings",size_hint=(.3,.05),pos_hint={'x':.4,'y':0})
        self.root.add_widget(b2)

        b3 = Button(text="Next",size_hint=(.3,.05),pos_hint={'x':.1,'y':0})
        b3.bind(on_press=self.root.next_trajectory)
        self.root.add_widget(b3)
        self.root.reset_game()
Example #3
0
    def save_notes(self):

        App.get_running_app().tog.next()
        Window.release_all_keyboards()
        self.data2['user']=self.user.text
        self.data2['pass']=self.passwor.text
        Clock.schedule_once(self.login_m,1)
    def on_touch_down(self, touch):
        """An override of ScatterPlane's on_touch_down.
           Used to determine the current selected widget and also emits,
           on_show_edit event.
        """

        if super(ScatterPlane, self).collide_point(*touch.pos) and not self.keyboard:
            win = EventLoop.window
            self.keyboard = win.request_keyboard(self._keyboard_released, self)
            self.keyboard.bind(on_key_down=self._on_keyboard_down)

        if super(ScatterPlane, self).collide_point(*touch.pos):
            if not self.dragging:
                self.touch = touch
                Clock.schedule_once(self.start_widget_dragging, 0.5)

            x, y = self.to_local(*touch.pos)
            target = self.find_target(x, y, self.root)
            self.selected_widget = target
            App.get_running_app().focus_widget(target)
            self.clicked = True
            self.dispatch("on_show_edit", Playground)
            return True

        if self.parent.collide_point(*touch.pos):
            super(Playground, self).on_touch_down(touch)

        return False
Example #5
0
				def on_back_pressed( self , *args ) :
					"""

					:return:
					"""

					App.get_running_app().logger.info( 'on_back' )
Example #6
0
 def run(self, startPoint = None):
   self.startPoint = startPoint
   self.regist(startPoint)
   # start method
   if hasattr(startPoint, "start"):
     self.startAppList.append(startPoint)
   App.run(self)
Example #7
0
    def _event_filter(self, action):
        from kivy.app import App
        if action == 'app_terminating':
            EventLoop.quit = True
            self.close()

        elif action == 'app_lowmemory':
            self.dispatch('on_memorywarning')

        elif action == 'app_willenterbackground':
            from kivy.base import stopTouchApp
            app = App.get_running_app()
            if not app:
                Logger.info('WindowSDL: No running App found, exit.')
                stopTouchApp()
                return 0

            if not app.dispatch('on_pause'):
                Logger.info('WindowSDL: App doesn\'t support pause mode, stop.')
                stopTouchApp()
                return 0

            self._pause_loop = True

        elif action == 'app_didenterforeground':
            # on iOS, the did enter foreground is launched at the start
            # of the application. in our case, we want it only when the app
            # is resumed
            if self._pause_loop:
                self._pause_loop = False
                app = App.get_running_app()
                app.dispatch('on_resume')

        return 0
Example #8
0
 def enter_gallery(self, instance):
     galleryinfo = [instance.gallery_id, instance.gallery_token,
                    instance.pagecount, instance.gallery_name,
                    instance.gallery_tags, instance.gallery_thumb, instance.filesize]
     existgallery = db.query(Gallery).filter_by(
         gallery_id=instance.gallery_id).first()
     if existgallery:
         pass
     else:
         gallery = Gallery(gallery_id=instance.gallery_id,
                           gallery_token=instance.gallery_token,
                           pagecount=instance.pagecount,
                           gallery_name=instance.gallery_name,
                           gallery_thumb=instance.gallery_thumb,
                           filesize=instance.filesize)
         db.add(gallery)
         db.commit()
         for tag in instance.gallery_tags:
             gallerytag = GalleryTags(galleryid=gallery.id, tag=tag)
             db.add(gallerytag)
             db.commit()
     preview_screen = App.get_running_app(
     ).root.ids.sadpanda_screen_manager.get_screen("gallery_preview_screen")
     preview_screen.gallery_id = instance.gallery_id
     App.get_running_app().root.next_screen("gallery_preview_screen")
Example #9
0
 def on_leave(self):
     '''write setting to logic and save to file'''
     for key in self.logic.settings:
         if key in self.setting_items:
             self.logic.settings[key] = self.setting_items[key].value
     self.logic.apply_settings()
     App.get_running_app().settings.save()
	def update_file_layout(self):
		auth_token='S2_xUq0_iNAAAAAAAAAACYNG1zf1GAzKpVWVfmLcZLA-FIiSlGxMvmxBkAtspuWQ'
		client = dropbox.client.DropboxClient(auth_token)
		self.clear_widgets()  
		b=BoxLayout(orientation='vertical')
		file_system = FileSystemLocal()
		root_dir= App.get_running_app().user_data_dir+'/';result_dir=root_dir+'results'
		file_list=file_system.listdir(root_dir)   # this returns a list of files in dir
		if os.path.exists(result_dir):file_list.extend(file_system.listdir(App.get_running_app().user_data_dir+'/'+'results'+'/'))
		file_list=[x for x in file_list if x[-4:]=='.csv']
		b.add_widget(Label(text='Select Files to Upload',bold=True,font_size=sp(25),size_hint_y= 0.1))      
		file_system = FileSystemLocal()
		file_list=file_system.listdir(App.get_running_app().user_data_dir+'/')   # this returns a list of files in dir
		file_list=[x for x in file_list if x[-4:]=='.csv']
		s=ScrollView(size_hint_y=0.75)
		g=GridLayout(cols=2,size_hint_y=None)
		for file_1 in file_list:
			c=CheckBox(active=False)
			l=Label(bold= True,font_size=sp(20),text=file_1,size_hint_y= None,height=70)
			self.check_boxes[c]=file_1
			g.add_widget(l);g.add_widget(c)
		g.bind(minimum_height=g.setter('height'))
		s.add_widget(g)
		b.add_widget(s)
		g_options=GridLayout(cols=2,size_hint_y= 0.1,orientation='horizontal')       
		g_options.add_widget(Button(text="Send",on_press=self.upload,font_size=sp(25)))
		g_options.add_widget(Button(text="Back",on_press=self.return_back,font_size=sp(25)))
		b.add_widget(g_options)
		self.add_widget(b)
Example #11
0
    def allowed_target_for(self, target, widget):
        '''This function is used to determine if widget could be added to
           target.
        '''
        # stop on complex widget
        t = target if widget else target.parent
        if isinstance(t, FileChooserListView):
            return False
        if isinstance(t, FileChooserIconView):
            return False

        # stop on custom widget but not root widget
        class_rules = App.get_running_app().root.\
            project_loader.class_rules
        root_widget = App.get_running_app().root.\
            project_loader.root_rule.widget

        # if we don't have widget, always return true
        if widget is None:
            return True

        is_widget_layout = isinstance(widget, Layout)
        is_target_layout = isinstance(target, Layout)
        if is_widget_layout and is_target_layout:
            return True

        if is_target_layout or isinstance(target, Carousel):
            return True

        return False
Example #12
0
    def do_paste(self):
        '''Paste the selected widget to the current widget
        '''
        parent = self.selected_widget
        if parent and self.widget_to_paste:
            class_rules = App.get_running_app().root.\
                project_loader.class_rules
            root_widget = App.get_running_app().root.\
                project_loader.root_rule.widget
            is_child_custom = False
            for rule in class_rules:
                if rule.name == type(parent).__name__:
                    is_child_custom = True
                    break

            # find appropriate parent to add widget_to_paste
            while parent:
                if isinstance(parent, Layout) and (not is_child_custom
                                                   or root_widget == parent):
                    break

                parent = parent.parent
                is_child_custom = False
                for rule in class_rules:
                    if rule.name == type(parent).__name__:
                        is_child_custom = True
                        break

            if parent is not None:
                self.add_widget_to_parent(self.widget_to_paste,
                                          parent,
                                          kv_str=self._widget_str_to_paste)
                self.widget_to_paste = None
    def on_touch_move(self, touch):
        if touch.grab_current is not self:
            return False
        
        handled = super(DwellOnScatter, self).on_touch_move(touch)
		
        
        if handled:
            if self.ignore_dwell is not True:
                #if self.collide_point(touch.x, touch.y): # check dwell on myself, not the kids (todo: refine?)
                if self.dwell_started_by_touch != touch:
                    self.dwell_started_counter = 0
                    if self.dwell_started_by_touch is not None:
                        root = App.get_running_app().root
                        root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell'])
                    self.dwell_started_by_touch = None
                    Clock.unschedule(self.process_dwell)
                else:
                    # rather than base the calculation on the last touch frame, which means the user might be so slow, that a dwell follows them
                    # base it on the original touch position, with the dwell_jitter_distance essentially mimicing a radius
                    # around which a point can be within for the dwell to not be cancelled out
                    diff = [abs(i-j) for i, j in zip(self.dwell_started_by_touch.opos,self.dwell_started_by_touch.pos)]
                    #if abs(self.dwell_started_by_touch.dx) >= self.dwell_jitter_distance_ignore or abs(self.dwell_started_by_touch.dy) >= self.dwell_jitter_distance_ignore:
                    if diff[0] >= self.dwell_jitter_distance_ignore or diff[1] >= self.dwell_jitter_distance_ignore:
                        self.dwell_started_counter = 0
                        if self.dwell_started_by_touch is not None:
                            root = App.get_running_app().root
                            root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell'])
                        self.dwell_started_by_touch = None
                        Clock.unschedule(self.process_dwell)
                    else:
                        pass # ignore little movements

        return handled
Example #14
0
 def run(self):
     con_error_cnt = 0
     while self.keep_running:
         print 'connecting to weather'
         try:
             owm_is_online = self.link.is_API_online()
         except:  # api_call_error.APICallError
             con_error_cnt += 1
             print 'connection to OWM API failed'
             if con_error_cnt < 10:
                 print 'will try again in 2 seconds'
                 time.sleep(2)  # wait 2 seconds before trying it again
                 continue
             else:
                 # quit if connection could not be est. 10 times in a row
                 print 'OWM API seems to be offline, quitting'
                 break
         con_error_cnt = 0  # reset connection error counter if connection was successful
         if owm_is_online:
             obs = self.link.weather_at_place(location_str)
             App.get_running_app().owm_thread_weather = obs.get_weather()
         else:
             App.get_running_app().owm_thread_weather = None
             print('OWM service is offline')
         time.sleep(owm_fetch_sleep_time)  # should be last statement in while loop
Example #15
0
    def logfile_end_and_save(self, temp, pres):
        t = time.localtime(App.get_running_app().root.ph.processStart)[0:6]
        t_string = self.get_pretty_print_time(t[3], t[4], t[5], "-")
        date = self.get_pretty_print_time(t[0], t[1], t[2], ".")
        profile_name = App.get_running_app().root.ph.profile.name
        file = open(self.get_log_directory()+"/"+ date + "_" + t_string + "_" + profile_name + ".txt", "w")
        # put logged data into file when process has finished
        for entity in self.logdata:
            file.write(entity)

        if len(temp) > 0:
            time_string = "Time: ["
            temp_string = "Temperature: ["
            pres_string = "Presssure: ["
            for i in range(0, len(temp)-1):
                temp_string = temp_string + str(round(temp[i][1], 2)) + ","
                pres_string = pres_string + str(round(pres[i][1], 2)) + ","
                time_string = time_string + str(round(temp[i][0], 2)) + ","

            temp_string = temp_string + str(temp[-1][1]) + "]"
            pres_string = pres_string + str(pres[-1][1]) + "]"
            time_string = time_string + str(temp[-1][0]) + "]"

            file.write("\n")
            file.write("Logged Temperature and Pressure Data")
            file.write("\n")
            file.write(time_string)
            file.write("\n")
            file.write(temp_string)
            file.write("\n")
            file.write(pres_string)
        file.close()
        # clear logdata
        self.logdata = []
        pass
Example #16
0
	def __init__(self, **kwargs):
		if hasattr(App.get_running_app(), 'theme_cls'):
			self._theme_cls = App.get_running_app().theme_cls
		else:
			self._theme_cls = ThemeManager()
		super(ThemeBehaviour, self).__init__(**kwargs)
		self._rip_color = self._theme_cls.ripple_color
Example #17
0
    def __init__(self, **kwargs):
        super(BTCommunicator, self).__init__(**kwargs)
        self.register_event_type('on__connected')
        self.register_event_type('on_dis_connected')
        self.register_event_type('on_command_sent')
        self.register_event_type('on_response')
        self.register_event_type('on_error')
        self.register_event_type('on_unknown')
        App.get_running_app().bind(on_stop=self.stop_reader_stream)
        curdir = dirname(__file__)
        try:
            with open(join(curdir, 'lang', '{}.json'.format(self.language))) as lang_file:
                self._lang = json.load(lang_file)
        except Exception as e:
            raise BTCommunicatorException("Couldn't load {}/lang/{}.json\nError: {}".format(curdir, self.language, e.message))

        if platform == 'android':
            self.BluetoothAdapter = jnius.autoclass('android.bluetooth.BluetoothAdapter')
            self.BluetoothDevice = jnius.autoclass('android.bluetooth.BluetoothDevice')
            self.BluetoothSocket = jnius.autoclass('android.bluetooth.BluetoothSocket')
            self.InputStreamReader = jnius.autoclass('java.io.InputStreamReader')
            self.BufferedReader = jnius.autoclass('java.io.BufferedReader')
            self.IOException = jnius.autoclass('java.io.IOException')
            self.UUID = jnius.autoclass('java.util.UUID')
        return
Example #18
0
 def hook_keyboard(self, window, key, *largs):
     if key == 27:
         if FlashcardAppManager.s_manager.current != 'menu':
             FlashcardAppManager.s_manager.current = 'menu'
         else:
             App.get_running_app().stop()
     return True 
Example #19
0
 def run_project(self, project):
     config = ConfigParser()
     config.read('config.ini')
     config.set('Project', 'open_project', project)
     with open('config.ini', 'wb') as configfile:
         config.write(configfile)
     App.get_running_app().stop()
Example #20
0
    def on_keyboard_down(self, keyboard, keycode, text, modifiers):

        key = keycode[1]
        print 'keyboard screen manager', key, text
        # general key bindings
        if key == 'q':
            App.get_running_app().stop()
            return True
        # key binding for the wall
        elif self.current == 'Wall screen':
            if ((key == 'up' and self.current_active_post_index > 0) or
                    (key == 'down' and self.current_active_post_index < self.number_of_posts - 1))\
                    and not self.movement_flag:
                next_index = self.current_active_post_index + 1 if key == 'down' else self.current_active_post_index - 1
                self.ids['pw'].scroll_wall(next_index)
                return True
            elif key == 'enter':
                self.ids['pc'].index = self.current_active_post_index
                self.current = 'Carousel screen'
                return True
        # key bindings for the carousel
        elif self.current == 'Carousel screen':
            if key == 'up' and self.current_active_post_index > 0 and not self.movement_flag:
                self.ids['pc'].load_previous()
                self.current_active_post_index -= 1
            elif key == 'down' and self.current_active_post_index < self.number_of_posts - 1 and not self.movement_flag:
                self.ids['pc'].load_next()
                self.current_active_post_index += 1
            elif key == 'backspace':
                self.ids['pw'].move_wall_to_index(self.current_active_post_index)
                self.current = 'Wall screen'
                return True
Example #21
0
 def update_tab_value(self, callback):
     if self.balance_input.text.isnumeric():
         App.get_running_app().man.customer_handler.update_tab_value(self.customer, float(self.balance_input.text))
         self.customer_layout.ids.balance_label.text = str(float(self.balance_input.text))
         self.dismiss()       
     else:
         self.info_label.text = "Not valid number"
Example #22
0
    def __init__(self):
        """

        :return:
        """
        App.__init__(self)

        # Connection
        self.connection = "DUMMY"
        self.proxy = Proxy(self.connection)
        self.proxy.start()

        # Model
        self.robot = SimulatedRobot(self.proxy)
        self.robot.cell_size = 0.3
        self.robot.x = 0.3
        self.robot.y = 0.3

        self.map_model = Map(self.robot, 3.0, 0.3)
        self.state = State.default
        self.brush = "start"

        self.planning_algorithm = GridNav(self.map_model)
        self.planner = Planner(self.robot, self.map_model, self.planning_algorithm, self.proxy)

        # View
        self.map_widget = None
        self.panel_widget = None
        self.toolbar_widget = None
        self.horizontal_layout = None
        self.vertical_layout = None
        self.popup = None

        self.plan()
Example #23
0
    def __init__(self):
        App.__init__(self)
        self.STACK= ExdStack()

        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down)
        self.keyEvents = {}
    def search_tag(self, instance):

        tag = instance.text
        search = Search(searchterm=tag)
        db.add(search)
        db.commit()
        App.get_running_app().root.next_screen("front_screen")
Example #25
0
    def on_touch_move(self, touch):
        if touch.grab_current is not self:
            return
        touch.push()
        touch.apply_transform_2d(self.to_local)
        ud = touch.ud

        # typecasting-problems during cross-compiling
        # leads to this ugly construction like in calc_hillbodies
        foo = App.get_running_app().config.get('planetapp','showtrajectorymode')
        trajectorylength = int(App.get_running_app().config.get('planetapp',
                                                                'trajectorylength'))
        if foo == u'0':
            ud['lines'][0].points = (ud['firstpos'][0],ud['firstpos'][1],
                                     touch.x,touch.y)
        else:
            velocity = ((ud['firstpos'][0] - touch.x) / -50, 
                        (ud['firstpos'][1] - touch.y) / - 50)
            planetpos = (ud['firstpos'][0], ud['firstpos'][1])
            sunpos = (self.width/2,self.height/2)
            trajectory = self.calc_trajectory(planetpos, velocity, 
                                              self.planetmass, sunpos, 
                                              self.sunmass, 1, 
                                              trajectorylength)  
            ud['lines'][0].points = trajectory

        touch.pop()
Example #26
0
 def upload_to_drive():
     google_client = DriveClient()
     google_client.upload_file(csv_name)
     App.get_running_app().settings.update_settings(update_time=time_str)
     os.remove(csv_name)            
     InformationPopup('File uploaded')
     Logger.info('CustomerHandler: upload thread finished')
Example #27
0
 def __init__(self):
     App.__init__(self)
     self.connected = True
     self.Connect((HOST, PORT))
     
     self.count = 0
     self.time = 0
Example #28
0
 def leave_game(self):
     """
     Ends the game by stopping the app
     :return:
     """
     # Exit the application, clean up
     App.get_running_app().stop()
Example #29
0
 def make_board_match_view_mode(self, name):
     board = self.get_screen(name)
     if self.view_mode[:6] == 'tablet':
         if not isinstance(board.children[0], TabletBoardView):
             print 'REFRESHING -> tbv'
             board = self.get_screen(name)
             self.close_board(name)
             board = board.children[0]
             board.board.save_sgf()
             filen = board.board.collectionsgf.filen
             reconstruction_path = board.board.get_reconstruction()
             new_pbv = self.new_board(from_file=filen, mode='Navigate')
             new_pbv.board.reconstruct_from(reconstruction_path)
             new_pbv.board.comment_pre_text = 'This [b]tablet mode[/b] is currently experimental. It should work fine, but is still being tested and will be subject to change (more efficient layout etc.) and speed optimisation before being finalised.\n-----\n'
             App.get_running_app().manager.refresh_open_games()
     else:
         if not isinstance(board.children[0], PhoneBoardView):
             print 'REFRESHING -> pbv'
             board = self.get_screen(name)
             self.close_board(name)
             board = board.children[0]
             board.board.save_sgf()
             filen = board.board.collectionsgf.filen
             reconstruction_path = board.board.get_reconstruction()
             new_pbv = self.new_board(from_file=filen, mode='Navigate')
             new_pbv.board.reconstruct_from(reconstruction_path)
             App.get_running_app().manager.refresh_open_games()
Example #30
0
    def submitGUI(self):
        """ Submit the GUI

        Get all settings, confirm they are valid, save new settings file

        """
        ## Error Check All GUI SETTINGS
        errorCheckPassed = self.check_GUI_settings()

        # write GUI settings to file
        if errorCheckPassed:
            # Convery the GUI_settings from kivy dictproperty to a regular ol'
            # python dict (and do some reformatting along the way)
            allSettings = {}
            for k in self.GUI_settings.keys():
                # convert text inputs to integers
                if k in ['pynealScannerPort', 'resultsServerPort', 'numTimepts']:
                        allSettings[k] = int(self.GUI_settings[k])
                else:
                    allSettings[k] = self.GUI_settings[k]

            # write the settings as the new config yaml file
            with open(setupConfigFile, 'w') as outputFile:
                yaml.dump(allSettings, outputFile, default_flow_style=False)

            # Close the GUI
            global submitButtonPressed
            submitButtonPressed = True
            App.get_running_app().stop()
            EventLoop.exit()
Example #31
0
 def setUVBackground(self):
     self.uvBackground = App.get_running_app().Obs['UVIndex'][3]
Example #32
0
 def no(self):
     App.get_running_app().stop()  # exit the application
Example #33
0
 def on_enter(self):
     play_stim_set(
         [App.get_running_app().stimulus,
          App.get_running_app().probe])
Example #34
0
 def on_enter(self):  # This code will run when exit screen is entered!
     print('in exit screen')
     print(
         App.get_running_app().response
     )  # Note this reference to the app class is an easy way to point to these properties!
Example #35
0
 def messages_checker(self, dt):
     while True:
         if App.get_running_app().is_connected == False:
             break
         else:
             # getting oraclesinfo for active room
             oracles_info = rpclib.oracles_info(
                 App.get_running_app().rpc_connection,
                 App.get_running_app().active_room_id)
             if App.get_running_app().active_room_id == '':
                 print("Seems messages grabbing works")
                 break
             else:
                 # flushing it to not print previous messages
                 baton_returned = {}
                 # getting batons to print on each iteration
                 data_to_print = {}
                 # getting dictionary with current batontxid for each publisher
                 for entry in oracles_info["registered"]:
                     baton_returned[entry["publisher"]] = entry["batontxid"]
             # updating batons for all publishers in app array
                 for publisher in baton_returned:
                     if publisher in App.get_running_app().current_baton:
                         # if publisher already here updating baton and adding it to print queue
                         if baton_returned[publisher] != App.get_running_app(
                         ).current_baton[publisher]:
                             App.get_running_app().current_baton[
                                 publisher] = baton_returned[publisher]
                             try:
                                 data_to_print[
                                     publisher] = rpclib.oracles_samples(
                                         App.get_running_app(
                                         ).rpc_connection,
                                         App.get_running_app(
                                         ).active_room_id,
                                         baton_returned[publisher],
                                         "1")['samples'][0][0]
                             except IndexError:
                                 break
             # if baton is the same as before there is nothing to update
                         else:
                             break
             # if publisher not here adding it with latest baton and adding baton to print queue
                     else:
                         App.get_running_app().current_baton[
                             publisher] = baton_returned[publisher]
                         try:
                             data_to_print[
                                 publisher] = rpclib.oracles_samples(
                                     App.get_running_app().rpc_connection,
                                     App.get_running_app().active_room_id,
                                     baton_returned[publisher],
                                     "1")['samples'][0][0]
                         except IndexError:
                             break
             # finally printing messages
             try:
                 for publisher in data_to_print:
                     message_list = ast.literal_eval(
                         data_to_print[publisher].replace('\r',
                                                          '\\r').replace(
                                                              '\n', '\\n'))
                     kvsearch_result = rpclib.kvsearch(
                         App.get_running_app().rpc_connection, publisher)
                     if 'value' in kvsearch_result:
                         addr = str(
                             P2PKHBitcoinAddress.from_pubkey(x(publisher)))
                         signature = kvsearch_result['value'][:88]
                         value = kvsearch_result['value'][88:]
                         verifymessage_result = rpclib.verifymessage(
                             App.get_running_app().rpc_connection, addr,
                             signature, value)
                         if verifymessage_result:
                             message_to_print = datetime.utcfromtimestamp(
                                 message_list[0]).strftime(
                                     '%D %H:%M') + '[' + kvsearch_result[
                                         'value'][88:] + '-' + publisher[
                                             0:10] + ']:' + message_list[1]
                         else:
                             message_to_print = 'IMPROPER SIGNATURE' + datetime.utcfromtimestamp(
                                 message_list[0]).strftime(
                                     '%D %H:%M') + '[' + kvsearch_result[
                                         'value'][88:] + '-' + publisher[
                                             0:10] + ']:' + message_list[1]
                     else:
                         message_to_print = datetime.utcfromtimestamp(
                             message_list[0]).strftime(
                                 '%D %H:%M') + '[' + publisher[
                                     0:10] + ']:' + message_list[1]
                     App.get_running_app().messages.append(message_to_print)
                     App.get_running_app(
                     ).root.ids.messagesview.adapter.data = App.get_running_app(
                     ).messages
                 break
             except bitcoinrpc.authproxy.JSONRPCException as e:
                 print(App.get_running_app().active_room_id)
                 print(e)
                 break
Example #36
0
 def send_message(instance, inputid):
     new_message = chatlib.message_sending(
         App.get_running_app().rpc_connection,
         App.get_running_app().active_room_id, str(inputid.text))
     print(new_message)
     inputid.text = ''
Example #37
0
 def subscribe_room(self, utxos_amount):
     chatlib.room_subscription(App.get_running_app().rpc_connection,
                               str(App.get_running_app().active_room_id),
                               utxos_amount)
Example #38
0
 def create_nickname(self, nickname, password):
     new_nickname = chatlib.set_nickname(
         App.get_running_app().rpc_connection, nickname, password)
     print(new_nickname)
Example #39
0
 def load_selected(self, selected):
     if not selected:
         return
     root = App.get_running_app().root
     root.set_namehash(selected)
     root.ids["convershash"].text = selected
Example #40
0
 def load_direct(self):
     root = App.get_running_app().root
     root.set_namehash(self.entry[1])
     root.ids["convershash"].text = self.entry[1]
Example #41
0
 def delete_friend_afterask(self):
     root = App.get_running_app().root
     ret = root.requester.requester.do_request("/client/delentity",
                                               {"name": self.text})
     if logcheck(ret):
         root.load_friends()
Example #42
0
 def add_friend_after(self, name):
     root = App.get_running_app().root
     self.entry[3] = name
     d = {"name": name, "hash": self.entry[1], "type": "client"}
     root.requester.requester.do_request("/client/addhash", d, {})
     self.update_friend()
Example #43
0
 def on_parent(self, instance, value):
     if value:
         app = App.get_running_app()
         self._back = _back = partial(self.ids.back.dispatch, 'on_release')
Example #44
0
 def show_error(self, msg):
     app = App.get_running_app()
     Clock.schedule_once(lambda dt: app.show_error(msg))
Example #45
0
 def on_dismiss(self):
     app = App.get_running_app()
     if app.wallet is None and not self._on_release:
         app.stop()
Example #46
0
 def on_parent(self, instance, value):
     if value:
         app = App.get_running_app()
         self._back = _back = partial(app.dispatch, 'on_back')
Example #47
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self._shadow = App.get_running_app().theme_cls.round_shadow
Example #48
0
#coding: utf-8
from kivy.app import App
from kivy.uix.label import Label


def build():

    lbl_text = Label()
    lbl_text.text = 'Curso de Python e Kivy'
    lbl_text.italic = True
    lbl_text.font_size = 50
    return lbl_text


iniciar = App()
iniciar.build = build
iniciar.run()
Example #49
0
 def setBarometerArrow(self):
     self.barometerArrow = App.get_running_app().Obs['Pres'][2]
Example #50
0
    def execute_run(self):
        valuation_home = self.manager.parent.parent.manager.get_screen(
            'valuation_home')
        ss = self.manager.get_screen('selection_summary')

        # Parse selection summary for arguments to pass to ValOp handler.
        wiz_selections = ss.wiz_selections
        iso = wiz_selections['iso']
        node = wiz_selections['node']
        nodeid = wiz_selections['nodeid']

        data_manager = App.get_running_app().data_manager
        rev_streams = data_manager.get_valuation_revstreams(
            iso, nodeid)[wiz_selections['rev_streams']]['market type']

        hist_data = wiz_selections['selected_data']
        device = wiz_selections['device']

        handler_requests = {}
        handler_requests['iso'] = iso
        handler_requests[
            'market type'] = rev_streams  # need this as string, not list
        handler_requests['months'] = [(entry['month'], entry['year'])
                                      for entry in hist_data]
        handler_requests['node id'] = nodeid
        handler_requests['param set'] = [{
            param.desc['attr name']: param.param_slider.value
            for param in device
        }]

        # Send requests to ValOp handler.
        valop_handler = valuation_home.handler
        valop_handler.solver_name = App.get_running_app().config.get(
            'optimization', 'solver')
        self.solved_ops, handler_status = valop_handler.process_requests(
            handler_requests)

        # If no optimizations were solved successfully, bail out.
        if not self.solved_ops:
            popup = WizardCompletePopup()

            popup.title = "Hmm..."
            popup.popup_text.text = "Unfortunately, none of the models were able to be solved. This is likely due to no data being available for the node selected. Try selecting another pricing node next time. (You selected {0}.)".format(
                node)
            popup.results_button.text = "Take me back"
            popup.bind(on_dismiss=lambda x: self.manager.parent.parent.manager.
                       nav_bar.go_up_screen())  # Go back to Valuation Home
            popup.open()
            return

        # Save selection summary details to pass to report generator.
        deviceSelectionButtons = self.manager.get_screen(
            'device_select').device_select.children
        selectedDeviceName = [
            x.text for x in deviceSelectionButtons if x.state == "down"
        ][0]

        self.report_attributes = {
            'market area':
            iso,
            'pricing node':
            node,
            'selected device':
            selectedDeviceName,
            'dates analyzed':
            ' to '.join([
                ' '.join([
                    calendar.month_name[int(hist_data[0]['month'])],
                    hist_data[0]['year']
                ]),
                ' '.join([
                    calendar.month_name[int(hist_data[-1]['month'])],
                    hist_data[-1]['year']
                ]),
            ]),
            'revenue streams':
            wiz_selections['rev_streams'],
            'market type':
            rev_streams,
        }

        for param in device:
            self.report_attributes[
                param.desc['attr name']] = param.param_slider.value

        popup = WizardCompletePopup()

        if not handler_status:
            popup.title = "Success!*"
            popup.popup_text.text = "All calculations finished. Press 'OK' to proceed to the results.\n\n*At least one model (month) had issues being built and/or solved. Any such model will be omitted from the results."

        popup.bind(on_dismiss=self._next_screen)
        popup.open()
Example #51
0
 def setLightningBoltIcon(self):
     if App.get_running_app().Obs['StrikeDeltaT'][4] != '-':
         if App.get_running_app().Obs['StrikeDeltaT'][4] < 360:
             self.lightningBoltIcon = 'lightningBoltStrike'
         else:
             self.lightningBoltIcon = 'lightningBolt'
Example #52
0
 def __init__(self, **kwargs):
     super(BarometerPanel, self).__init__(**kwargs)
     App.get_running_app().BarometerPanel = self
     self.setBarometerArrow()
Example #53
0
 def __init__(self, **kwargs):
     super(RainfallPanel, self).__init__(**kwargs)
     App.get_running_app().RainfallPanel = self
     Clock.schedule_once(self.Clock)
     self.animateRainRate()
Example #54
0
 def __init__(self, **kwargs):
     super(LightningPanel, self).__init__(**kwargs)
     App.get_running_app().LightningPanel = self
     self.setLightningBoltIcon()
Example #55
0
 def on_pre_enter(self):
     self.lbl.value = 1
     App.get_running_app().response_made = False
Example #56
0
 def __init__(self, **kwargs):
     super(MoonPhasePanel, self).__init__(**kwargs)
     App.get_running_app().MoonPhasePanel = self
Example #57
0
 def __init__(self, **kwargs):
     super(WindSpeedPanel, self).__init__(**kwargs)
     App.get_running_app().WindSpeedPanel = self
     self.setWindIcons()
Example #58
0
 def setWindIcons(self):
     self.windDirIcon = App.get_running_app().Obs['WindDir'][2]
     self.windSpdIcon = App.get_running_app().Obs['WindSpd'][3]
Example #59
0
 def slide_response(self, *args):
     App.get_running_app().response = round(args[1], 1)
     App.get_running_app().response_made = True
Example #60
0
 def __init__(self, **kwargs):
     super(SunriseSunsetPanel, self).__init__(**kwargs)
     App.get_running_app().SunriseSunsetPanel = self
     self.setUVBackground()