Example #1
0
 def join_train(self, data):
     self.client.params.lr = data.get('lr', self.client.params.lr)
     self.client.model = data.get('model', None)
     if data['model_name'] == "LR":
         features = input_size(data['model_name'], "mnist")
         self.client.model = LogisticRegression(features, lr=self.client.params.lr)
         self.client.model.batch_size = adaptive_batch_size(self.client.profile)
         self.client.log(log="Joined training, waiting to start ...")
     else:
         toast(f"Model {data['model_name']} not supported.")
         exit(0)
Example #2
0
 def share(self):
     if self.loca:
         url = f"{URL}{self.loca[0]},{self.loca[1]},10z/"
         sendIntent = Intent()
         sendIntent.setAction(Intent.ACTION_SEND)
         sendIntent.putExtra(Intent.EXTRA_TEXT, String(url))
         sendIntent.setType("text/plain")
         shareIntent = Intent.createChooser(sendIntent, String('Share...'))
         mActivity.startActivity(shareIntent)
     else:
         toast('No location', True, 80)
 def share(self):
     if self.loca:
         url = f"https://www.google.com/maps/search/@{self.loca[0]},{self.loca[1]},10z/"
         sendIntent = Intent()
         sendIntent.setAction(Intent.ACTION_SEND)
         sendIntent.putExtra(Intent.EXTRA_TEXT, String(url))
         sendIntent.setType("text/plain")
         shareIntent = Intent.createChooser(sendIntent, String('Share...'))
         mActivity.startActivity(shareIntent)
     else:
         toast('No location')
Example #4
0
    def open_navigation(self, lon, lat, mode, *largs):

        s = f'google.navigation:q={lon},{lat}&mode={mode}'
        intent = Intent(Intent.ACTION_VIEW, Uri.parse(s))
        intent.setPackage("com.google.android.apps.maps")

        if intent.resolveActivity(mActivity.getPackageManager()):
            mActivity.startActivity(intent)
        else:
            toast('No google maps found!\nInstall it from Play Store', True,
                  80)
 def playlist_add(self, song, index=-1):
     self.app.playlist = self.app.db.get_playlist()
     if song not in self.app.playlist.tracks:
         if index == -1:
             self.app.playlist.tracks.append(song)
         else:
             self.app.playlist.tracks.insert(index, song)
         self.app.db.add_playlist_track(song, index)
         toast('Song added to playlist')
     else:
         toast('Song already in playlist')
Example #6
0
 def menu_callback(self, instance_menu, instance_menu_item):
     if instance_menu_item.text.lower() == "edit":
         self.edit = self.mock
     elif instance_menu_item.text.lower() == "delete":
         self.delete = self.mock
     elif instance_menu_item.text.lower() == "copy":
         Clipboard.copy(json.dumps(asdict(self.mock)))
         toast('Copied !!!')
     elif instance_menu_item.text.lower() == "favorite":
         self.favorite = self.mock
     instance_menu.dismiss()
Example #7
0
    def select_path(self, path):
        """It will be called when you click on the file name
        or the catalog selection button.

        :type path: str;
        :param path: path to the selected directory or file;

        """

        self.exit_manager()
        toast(path)
Example #8
0
    def parse(self):
        try:
            portfolio = ExportImportOperation.text_imp(self.ids.data.text)

            pw = PortfolioView()
            pw.load(portfolio)
            pw.open()
            self.dismiss()
        except Exception as e:
            toast(strings.TEXT_PORTFOLIO_IMPORTER_FAILURE)
            logging.exception(e)
Example #9
0
    def start_server(self):
        logging.info("started")
        try:
         if(self.port_number):
            print(self.port_number)
        except:
          self.port_number=1024

        authorizer = DummyAuthorizer()
        try: 
            try:
             authorizer.add_user(str(self.username),str(self.password),'.', perm='elradfmwMT')
            
            except AttributeError:
                try:
                 authorizer.add_user(str(self.username),'12345','.', perm='elradfmwMT')
                
                except:
                 authorizer.add_user('user',str(self.password),'.', perm='elradfmwMT')
                 


        except AttributeError :
            authorizer.add_user('user', '12345', '.', perm='elradfmwMT')
        self.proceed,self.wl_ip=get_wl_ip() 
        if(self.proceed==True):
            logging.info("passed")
            # authorizer.add_anonymous(os.path.join(self.path_sd))###for android
            authorizer.add_anonymous(os.getcwd())# for desktop mention path
            # logging.info(os.listdir(self.path_sd))
            handler = FTPHandler
            handler.authorizer = authorizer
            handler.banner = "pyftpdlib based ftpd ready."
            try:
             handler.passive_ports = range(self.range1,self.range2)
             logging.info("changed passive ports")
            except:
             handler.passive_ports=range(2300,2399)
             logging.info("default passive ports")
            logging.info(self.wl_ip)
            logging.info(self.port_number)
            address = (self.wl_ip, self.port_number)
            self.server = ThreadedFTPServer(address, handler)
            logging.info(self.server)
            self.server.max_cons = 256
            self.server.max_cons_per_ip = 5
            logging.info("passed that max_cons")
            t1=threading.Thread(target=run_,args=(self.server,self.port_number))
            logging.info("thread assigned")
            t1.start()
            self.show_notification()
            logging.info("Thread started")
        else:
            toast("Try turning on hotspot and try again")
Example #10
0
    def checkUpdates(self, ava=False, d=False):
        upCURL = 'https://raw.githubusercontent.com/biplobsd/proxySpeedTestApp/master/updates.json'  # noqa update-check-link
        # from json import load
        # with open('updates.json', 'r') as read:
        #     updateinfo = load(read)
        # toast("Checking for any updates ...")
        try:
            updateinfo = get(upCURL, verify=False, timeout=1).json()
        except:  # noqa
            toast("Unable to get updates information")
            return False
        try:
            appLink = updateinfo["release"][platform]
        except KeyError:
            appLink = ""
        title = f"App update v{updateinfo['version']} {platform}"
        msg = "You are already in latest version!"
        b1 = "CENCEL"
        force = False

        if updateinfo['version'] > float(self.version) and appLink != "":
            if updateinfo['messages']:
                title = updateinfo['messages']
            msg = ""
            b2 = "DOWNLOAD"
            force = bool(updateinfo['force'])
            if force:
                b1 = "EXIT"
            ava = True
        else:
            b2 = "CHECK"

        self.updateDialog = MDDialog(
            title=title,
            text=msg+updateinfo[
                'changelogs']+f"\n\n[size=15]Force update: {force}[/size]",
            auto_dismiss=False,
            buttons=[
                MDFlatButton(
                    text=b1,
                    text_color=self.theme_cls.primary_color,
                    on_release=lambda x:self.updateDialog.dismiss() if b1 == "CENCEL" else self.stop()  # noqa
                ),
                MDRaisedButton(
                    text=b2,
                    on_release=lambda x:open_link(appLink) if b2 == "DOWNLOAD" else self.FCU(self.updateDialog),  # noqa
                    text_color=self.theme_cls.primary_light,
                ),
            ],
        )
        self.updateDialog.ids.title.theme_text_color = "Custom"
        self.updateDialog.ids.title.text_color = self.theme_cls.primary_light  # noqa
        if ava:
            self.updateDialog.open()
Example #11
0
    def download(self):
        self.song_name = self.ids.SongName.text

        args = {
            "no_encode": False,
        }
        spotdl_handler = Spotdl(args)
        spotdl_handler.download_track(self.song_name)
        self.manager.transition = FadeTransition(duration=1.2)
        self.manager.current = "Downloader"
        toast("Download complete")
Example #12
0
 def select_path(self, path):
     '''It will be called when you click on the file name
     or the catalog selection button.
     :type path: str;
     :param path: path to the selected directory or file;
     '''
     self.exit_manager()
     print(path)
     toast(path)
     path = "D:" + path
     self.start_music(path)
Example #13
0
 def sort_list(self):
     """
     Will sort the internal list in alphabetic order.
     :return:
     """
     self.set_list(
         sorted(self._list,
                key=lambda playlist_provider: str(playlist_provider.
                                                  file_path.stem)))
     self.filter_list()
     toast("Playlists sorted")
Example #14
0
 def sign_in_failure(self, urlrequest, failure_data):
     """Displays an error message to the user if their attempt to create an
     account was invalid.
     """
     self.hide_loading_screen()
     self.email_not_found = False  # Triggers hiding the sign in button
     msg = failure_data['error']['message'].replace("_", " ").capitalize()
     toast(msg)
     if msg == "Email not found":
         self.email_not_found = True
     if self.debug:
         print("Couldn't sign the user in: ", failure_data)
Example #15
0
 def sign_up_failure(self, urlrequest, failure_data):
     """Displays an error message to the user if their attempt to log in was
     invalid.
     """
     self.hide_loading_screen()
     self.email_exists = False  # Triggers hiding the sign in button
     msg = failure_data['error']['message'].replace("_", " ").capitalize()
     toast(msg)
     if msg == "Email exists":
         self.email_exists = True
     if self.debug:
         print("Couldn't sign the user up: ", failure_data)
 def saveIp(self):
     con = sql.connect('db.db')
     cur = con.cursor()
     cur.execute("""DELETE  FROM adresse """)
     con.commit()
     self.local = self.root.ids.wifi.text
     self.internet = self.root.ids.internet.text
     cur.execute("""INSERT INTO adresse (local,internet) VALUES (?,?)""",
                 (self.local, self.internet))
     con.commit()
     con.close()
     toast("sauvgardé")
Example #17
0
def save_data(self, name_x):
    SERVER_HOST = name_x
    SERVER_PORT = 502
    c = ModbusClient()
    c.host(SERVER_HOST)
    c.port(SERVER_PORT)

    if not c.is_open():
        if not c.open():
            toast("failed")
    if c.is_open():
        toast("connected")
Example #18
0
 def on_init_response_is_authorized(self, is_authorized):
     '''
     called from tele_utils when the process of authorization is done, and there is a result
     :return: void
     '''
     print('on_init_response_is_authorized: ', is_authorized)
     if is_authorized:
         toast('You are authorized, well done!')
         self.navigate_to(constants.SCREEN_DIALOGS)
     else:
         toast('You are not authorized, please insert your number')
         self.navigate_to(constants.SCREEN_SIGN_IN_PHONE)
 def callback_delete(self, name_to_delete, delete_type, *args):
     if args[0] == "Yes":
         if delete_type == "delete_publisher":
             response = database_interface.delete_publisher(name_to_delete)
             if response[1]:
                 self.setup_publisher()
             toast(response[0])
         elif delete_type == "delete_city":
             response = database_interface.delete_city(name_to_delete)
             if response[1]:
                 self.setup_city()
             toast(response[0])
Example #20
0
    def dialog_exit(self):
        def check_interval_press(interval):
            self.exit_interval += interval
            if self.exit_interval > 5:
                self.exit_interval = False
                Clock.unschedule(check_interval_press)

        if self.exit_interval:
            sys.exit(0)
            
        Clock.schedule_interval(check_interval_press, 1)
        toast(self.translation._('Press Back to Exit'))
Example #21
0
    def data(self):
        def remove_match_char(list1, list2):
            for i in range(len(list1)):
                for j in range(len(list2)):
                    if list1[i] == list2[j]:
                        c = list1[i]
                        list1.remove(c)
                        list2.remove(c)
                        list3 = list1 + ["*"] + list2
                        return [list3, True]
            list3 = list1 + ["*"] + list2
            return [list3, False]

        p1 = self.root.ids.person1.text
        p1 = p1.lower()
        p1.replace(" ", "")
        p1_list = list(p1)

        p2 = self.root.ids.person2.text
        p2 = p2.lower()
        p2.replace(" ", "")
        p2_list = list(p2)

        proceed = True
        if len(p1_list) == 0 and len(p2_list) == 0:
            toast("Please Enter both the Names")
        else:
            while proceed:
                ret_list = remove_match_char(p1_list, p2_list)
                con_list = ret_list[0]
                proceed = ret_list[1]
                star_index = con_list.index("*")
                p1_list = con_list[:star_index]
                p2_list = con_list[star_index + 1:]
            count = len(p1_list) + len(p2_list)
            result = [
                "Friends", "Love", "Affection", "Marriage", "Enemy", "Siblings"
            ]

            while len(result) > 1:
                split_index = (count % len(result) - 1)
                if split_index >= 0:
                    right = result[split_index + 1:]
                    left = result[:split_index]
                    result = right + left
                else:
                    result = result[:len(result) - 1]

            toast("You Both are " + result[0])
            #close_result= MDRaisedButton(text='Close')
            dialog = MDDialog(title="Your Relationship is " + str(result[0]),
                              size_hint=(0.4, 0))
            dialog.open()
Example #22
0
        def delete(self, *name):
            try:
                name = name[0]
                toast('Delete Success')
                del self.data[name]
                with open('data/data.json', 'w') as f:

                    json.dump(self.data, f)
                self.visualize_json()
                self.close_dialog()
            except:
                pass
Example #23
0
 def fetch_api(self):  #fetch api and update home page
     try:
         url_ = url
         content = requests.get(url_).json()
         print(content)
         for items in content:
             name = items['name']
             price = items['price']
             image = items['image']
             self.create_widgets(name, image, price)
     except:
         toast("Failed")
Example #24
0
 def new_tag(self):
     tag = self.profilescreen.ids.tags.text
     if len(self.user['tags']) >= 4:
         toast("you can have 4 tags at most :( ")
         return
     if tag:
         self.profilescreen.ids.tag_box.add_widget(
             TagChip(label=tag, icon="coffee"))
         self.user['tags'].append(tag)
         self.tag_add([tag])
     else:
         toast("type something!")
Example #25
0
    def remove_selected_widget(self):
        if uiApp.current_selected_widget != None:
            if isinstance(uiApp.current_selected_widget, DraggableWire):

                self.buildersccreen.container.remove_widget(
                    uiApp.current_selected_widget.parent.parent.parent.parent.
                    parent)  # <<<<--- referring to wirebase class
            else:
                self.buildersccreen.container.remove_widget(
                    uiApp.current_selected_widget)
        else:
            toast("select a item first!")
Example #26
0
    def select_path(self, path):
        '''It will be called when you click on the file name
        or the catalog selection button.

        :type path: str;
        :param path: path to the selected directory or file;
        '''

        self.exit_manager()
        shutil.copy(path, 'codigo/Empresas')
        print(path)
        toast(path)
Example #27
0
 def send(self, msg):
     try:
         if self.terminate:
             self.log('log', f"Tries to send to bridge on terminated", remote=False)
         length = struct.pack('>Q', len(msg))
         self.sock.sendall(length)
         self.sock.sendall(msg)
     except socket.error as e:
         self.terminate = True
         toast('error', f"Bridge Socket error: {e}: ")
     except Exception as e:
         toast('error', f"Bridge send Exception\n{e}")
Example #28
0
    def on_dismiss_callback(instance):
        """
        Callback fired on dismissal of the PlayList ModalView
        :param instance: the instance of the ModalView itself, a non-static implementation would have passed 'self'
        :return: True prevents the modal view from closing
        """
        if instance.block_close:
            toast(f"Blocked closing")
        else:
            instance.restore_former_theme_context_menus()

        return instance.block_close
Example #29
0
    def baglan(self):

        SERVER_HOST = self.data
        SERVER_PORT = 502
        toggle = True
        c.host(SERVER_HOST)
        c.port(SERVER_PORT)
        toast("connection is OK")
        if not c.is_open():
            if not c.open():
                toast("connection fail")
                print("connection fail")
Example #30
0
def _delete_table():
    """Callback for deleting database table"""
    app = MDApp.get_running_app() ## App object reference
    try:
        lib.data_cls.drop_table()
    except lib.utils.NotAbleToDeleteDB:
        toast('Impossível apagar dados!', 1)
    else:
        toast('PCD apagado com sucesso!', 2)
        app.pcd_tree.regen_tree() ## regens tree after droping table
        app.root.ids.data_frame.clear_widgets() ## clears form widget
        app.pcd_tree.disabled = False ## Unlocks treeview