Example #1
0
 def status(self):
     toast("Calculating...")
     status = Status()
     if status == "Good":
         SweetAlert().fire(
             "Good",
             type='success',
         )
     elif status == "Not bad":
         SweetAlert().fire(
             "Not bad",
             type='info'
         )
     elif status == "Bad":
         SweetAlert().fire(
             "Not bad",
             type='question'
         )
     elif status == "Very bad":
         SweetAlert().fire(
             "Very bad",
             type='warning'
         )
     elif status == "Not work":
         SweetAlert().fire(
             "Not work",
             type='failure'
         )
 def export_transaction_csv(self):
     if export_the_transactions():
         Clipboard.copy(MY_TRANSACTION_EXPORT_PATH)
         SweetAlert().fire(
             f"CSV file created in {MY_TRANSACTION_EXPORT_PATH} directory, The directory has been copied to your clipboard.",
             type='success',
         )
     else:
         SweetAlert().fire(
             "You have not a transaction",
             type='failure',
         )
Example #3
0
 def Wallet_Delete(self):
     if not the_settings()["wallet"] == 0:
         self.show_delete_wallet_alert_dialog()
     else:
         SweetAlert().fire(
             "First wallet cannot be deleted.",
             type='failure',
         )
Example #4
0
 def callback_for_menu_items(self, *args):
     if not args[0] == the_settings()["wallet"]:
         change_wallet(int(args[0]))
         self.reflesh_balance()
     Clipboard.copy(Wallet_Import(int(args[0]), 3))
     SweetAlert().fire(
         "The address has been copied to your clipboard.",
         type='success',
     )
Example #5
0
 def show_help(self, *args):
     SweetAlert(
         animation_type="pulse",
         color_button=get_color_from_hex('008080'),
         font_style_text="Body2",
     ).fire(
         type="info",
         text="Application regroupant les différents scripts de la communauté.\n" + \
         "Dans le but de pouvoir les utiliser depuis une interface graphique",
     )
Example #6
0
 def show_wallet_alert_dialog(self):
     if not self.wallet_alert_dialog:
         self.wallet_alert_dialog = SweetAlert(
             title="Creating a wallet",
             type="custom",
             auto_dismiss=False,
             content_cls=Create_Wallet_Box(),
             buttons=[
                 MDFlatButton(
                     text="CANCEL",
                     on_press=self.dismiss_wallet_alert_dialog,
                     font_size="18sp",
                     font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
                 MDFlatButton(text="OK",
                              font_size="18sp",
                              font_name=self.FONT_PATH +
                              "RobotoCondensed-Bold",
                              on_press=self.create_the_wallet)
             ],
         )
     self.wallet_alert_dialog.open()
Example #7
0
 def show_start_node_server_dialog(self):
     if not self.start_node_server_dialog:
         self.start_node_server_dialog = SweetAlert(
             title="Start Node Server",
             type="custom",
             auto_dismiss=False,
             content_cls=start_node_server_Box(),
             buttons=[
                 MDFlatButton(
                     text="CANCEL",
                     on_press=self.dismiss_start_node_server_dialog,
                     font_size= "18sp",
                     font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
                 MDFlatButton(
                     text="OK",
                     on_press=self.start_node_server_func,
                     font_size= "18sp",
                     font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
             ],
         )
     self.start_node_server_dialog.open()
 def show_send_coin_dialog(self):
     if not self.send_coin_dialog:
         self.send_coin_dialog = SweetAlert(
             title="Send Coin",
             type="custom",
             auto_dismiss=False,
             content_cls=Send_Coin_Box(),
             buttons=[
                 MDFlatButton(
                     text="CANCEL",
                     on_press=self.dismiss_send_coin_dialog,
                     font_size="18sp",
                     font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
                 MDFlatButton(
                     text="OK",
                     on_press=self.sent_the_coins,
                     font_size="18sp",
                     font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
             ],
         )
     self.send_coin_dialog.open()
Example #9
0
 def show_add_unl_node_dialog(self):
     if not self.add_unl_node_dialog:
         self.add_unl_node_dialog = SweetAlert(
             title="Add UNL Node",
             type="custom",
             auto_dismiss=False,
             content_cls=add_unl_node_Box(),
             buttons=[
                 MDFlatButton(
                     text="CANCEL",
                     on_press=self.dismiss_add_unl_node_dialog,
                     font_size= "18sp",
                     font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
                 MDFlatButton(
                     text="OK",
                     on_press=self.add_unl_node_func,
                     font_size= "18sp",
                     font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                 ),
             ],
         )
     self.add_unl_node_dialog.open()
    def sent_the_coins(self, widget):

        text_list = self.get_send_coin_dialog_text()
        receiver_adress = text_list[2]
        amount = text_list[1]

        if not float(amount) < GetBlock().minumum_transfer_amount:
            if Wallet_Import(int(the_settings()["wallet"]), 2) == sha256(
                    text_list[0].encode("utf-8")).hexdigest():
                send_coin(float(amount), receiver_adress, text_list[0])
            else:
                SweetAlert().fire(
                    "Password is not correct",
                    type='failure',
                )
            del text_list

        self.send_coin_dialog.dismiss()
    def transaction_history(self):
        transactions = GetMyTransaction()
        if not len(transactions) == 0:
            bottom_sheet_menu = MDListBottomSheet(radius=25, radius_from="top")
            data = {}
            for tx in transactions:
                data[tx] = tx.toUser + " | " + str(tx.amount) + " | " + str(
                    tx.transaction_fee)

            for item in data.items():
                bottom_sheet_menu.add_item(
                    item[1],
                    lambda x, y=item[0]: self.
                    callback_for_transaction_history_items(y),
                )
            bottom_sheet_menu.open()
        else:
            SweetAlert().fire(
                "You have not a transaction",
                type='failure',
            )
Example #12
0
    def view_repos(self, **kwargs):
        SweetAlert(color_button=get_color_from_hex('008080'),
                   animation_type="pulse").fire(
                       text="Le repos a été ouvert dans votre navigateur.")

        webbrowser.open('https://github.com/iTeam-S/Outils')
Example #13
0
 def nd_id(self):
     Clipboard.copy(ndid())
     SweetAlert().fire(
         "The ID has been copied to your clipboard.",
         type='success',
     )
class OperationBox(MDGridLayout):
    cols = 2
    send_coin_dialog = None
    export_transaction_csv_dialog = None
    FONT_PATH = f"{os.environ['DECENTRA_ROOT']}/gui_lib/fonts/"

    def show_send_coin_dialog(self):
        if not self.send_coin_dialog:
            self.send_coin_dialog = SweetAlert(
                title="Send Coin",
                type="custom",
                auto_dismiss=False,
                content_cls=Send_Coin_Box(),
                buttons=[
                    MDFlatButton(
                        text="CANCEL",
                        on_press=self.dismiss_send_coin_dialog,
                        font_size="18sp",
                        font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                    MDFlatButton(
                        text="OK",
                        on_press=self.sent_the_coins,
                        font_size="18sp",
                        font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                ],
            )
        self.send_coin_dialog.open()

    def get_send_coin_dialog_text(self):
        text_list = []
        for obj in self.send_coin_dialog.content_cls.children:
            for sub_obj in obj.children:
                text_list.append(sub_obj.text)

                sub_obj.text = ""

        return text_list

    def sent_the_coins(self, widget):

        text_list = self.get_send_coin_dialog_text()
        receiver_adress = text_list[2]
        amount = text_list[1]

        if not float(amount) < GetBlock().minumum_transfer_amount:
            if Wallet_Import(int(the_settings()["wallet"]), 2) == sha256(
                    text_list[0].encode("utf-8")).hexdigest():
                send_coin(float(amount), receiver_adress, text_list[0])
            else:
                SweetAlert().fire(
                    "Password is not correct",
                    type='failure',
                )
            del text_list

        self.send_coin_dialog.dismiss()

    def dismiss_send_coin_dialog(self, widget):
        self.get_send_coin_dialog_text()

        self.send_coin_dialog.dismiss()

    def send_coin(self):
        self.show_send_coin_dialog()

    def export_transaction_csv(self):
        if export_the_transactions():
            Clipboard.copy(MY_TRANSACTION_EXPORT_PATH)
            SweetAlert().fire(
                f"CSV file created in {MY_TRANSACTION_EXPORT_PATH} directory, The directory has been copied to your clipboard.",
                type='success',
            )
        else:
            SweetAlert().fire(
                "You have not a transaction",
                type='failure',
            )

    def callback_for_transaction_history_items(self, widget):
        pass

    def transaction_history(self):
        transactions = GetMyTransaction()
        if not len(transactions) == 0:
            bottom_sheet_menu = MDListBottomSheet(radius=25, radius_from="top")
            data = {}
            for tx in transactions:
                data[tx] = tx.toUser + " | " + str(tx.amount) + " | " + str(
                    tx.transaction_fee)

            for item in data.items():
                bottom_sheet_menu.add_item(
                    item[1],
                    lambda x, y=item[0]: self.
                    callback_for_transaction_history_items(y),
                )
            bottom_sheet_menu.open()
        else:
            SweetAlert().fire(
                "You have not a transaction",
                type='failure',
            )
Example #15
0
class NodeBox(MDGridLayout):
    cols = 2
    FONT_PATH = f"{os.environ['DECENTRA_ROOT']}/gui_lib/fonts/"

    # Start Node Server
    start_node_server_dialog = None
    def show_start_node_server_dialog(self):
        if not self.start_node_server_dialog:
            self.start_node_server_dialog = SweetAlert(
                title="Start Node Server",
                type="custom",
                auto_dismiss=False,
                content_cls=start_node_server_Box(),
                buttons=[
                    MDFlatButton(
                        text="CANCEL",
                        on_press=self.dismiss_start_node_server_dialog,
                        font_size= "18sp",
                        font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                    MDFlatButton(
                        text="OK",
                        on_press=self.start_node_server_func,
                        font_size= "18sp",
                        font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                ],
            )
        self.start_node_server_dialog.open()


    def get_start_node_server_dialog_text(self):
        text_list = []
        for obj in self.start_node_server_dialog.content_cls.children:
            for sub_obj in obj.children:
                text_list.append(sub_obj.text)
                sub_obj.text = ""

        return text_list  
    def start_node_server_func(self, widget):
        text_list = self.get_start_node_server_dialog_text()
        ip = text_list[1]
        port = text_list[0]

        print(ip)
        print(port)
        
        ndstart(ip, int(port))

        self.start_node_server_dialog.dismiss()
    def dismiss_start_node_server_dialog(self,widget):
        self.get_start_node_server_dialog_text()

        self.start_node_server_dialog.dismiss()


    def start_node_server(self):
        self.show_start_node_server_dialog()
    # End


    def stop_node_server(self):
        ndstop()
    def connect_to_know_node(self):
        ndconnectmixdb()


    # Connect a Node

    connect_a_node_dialog = None
    def show_connect_a_node_dialog(self):
        if not self.connect_a_node_dialog:
            self.connect_a_node_dialog = SweetAlert(
                title="Connect a Node",
                type="custom",
                auto_dismiss=False,
                content_cls=start_node_server_Box(),
                buttons=[
                    MDFlatButton(
                        text="CANCEL",
                        on_press=self.dismiss_connect_a_node_dialog,
                        font_size= "18sp",
                        font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                    MDFlatButton(
                        text="OK",
                        on_press=self.connect_a_node_func,
                        font_size= "18sp",
                        font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                ],
            )
        self.connect_a_node_dialog.open()


    def get_connect_a_node_dialog_text(self):
        text_list = []
        for obj in self.connect_a_node_dialog.content_cls.children:
            for sub_obj in obj.children:
                text_list.append(sub_obj.text)
                sub_obj.text = ""

        return text_list  
    def connect_a_node_func(self,widget):
        text_list = self.get_connect_a_node_dialog_text()
        ip = text_list[1]
        port = text_list[0]

        print(ip)
        print(port)
        
        ndconnect(ip, int(port))

        self.connect_a_node_dialog.dismiss()
    def dismiss_connect_a_node_dialog(self,widget):
        self.get_connect_a_node_dialog_text()

        self.connect_a_node_dialog.dismiss()

    def connect_a_node(self):
        self.show_connect_a_node_dialog()
    # End   

    # Add UNL Node

    add_unl_node_dialog = None
    def show_add_unl_node_dialog(self):
        if not self.add_unl_node_dialog:
            self.add_unl_node_dialog = SweetAlert(
                title="Add UNL Node",
                type="custom",
                auto_dismiss=False,
                content_cls=add_unl_node_Box(),
                buttons=[
                    MDFlatButton(
                        text="CANCEL",
                        on_press=self.dismiss_add_unl_node_dialog,
                        font_size= "18sp",
                        font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                    MDFlatButton(
                        text="OK",
                        on_press=self.add_unl_node_func,
                        font_size= "18sp",
                        font_name= self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                ],
            )
        self.add_unl_node_dialog.open()


    def get_add_unl_node_dialog_text(self):
        text_list = []
        for obj in self.add_unl_node_dialog.content_cls.children:
            for sub_obj in obj.children:
                text_list.append(sub_obj.text)
                sub_obj.text = ""

        return text_list  
    def add_unl_node_func(self,widget):
        text_list = self.get_add_unl_node_dialog_text()
        pubkey = text_list[0]

        print(pubkey)

        from node.unl import save_new_unl_node
        save_new_unl_node(pubkey)        

        self.add_unl_node_dialog.dismiss()
    def dismiss_add_unl_node_dialog(self,widget):
        self.get_add_unl_node_dialog_text()

        self.add_unl_node_dialog.dismiss()

    def add_unl_node(self):
        self.show_add_unl_node_dialog()
    # End
    def get_block(self):
        if the_settings()["test_mode"]:
            CreateBlock()
        else:
            GetBlockFromOtherNode()

    def nd_id(self):
        Clipboard.copy(ndid())
        SweetAlert().fire(
            "The ID has been copied to your clipboard.",
            type='success',
        )

    def status(self):
        toast("Calculating...")
        status = Status()
        if status == "Good":
            SweetAlert().fire(
                "Good",
                type='success',
            )
        elif status == "Not bad":
            SweetAlert().fire(
                "Not bad",
                type='info'
            )
        elif status == "Bad":
            SweetAlert().fire(
                "Not bad",
                type='question'
            )
        elif status == "Very bad":
            SweetAlert().fire(
                "Very bad",
                type='warning'
            )
        elif status == "Not work":
            SweetAlert().fire(
                "Not work",
                type='failure'
            )
Example #16
0
    def create_project(
        self,
        _application_title,
        _project_name,
        _application_version,
        _path_to_project,
        _author_name,
    ):

        (
            APPLICATION_TITLE,  # NOQA: N806
            PROJECT_NAME,  # NOQA: N806
            APPLICATION_VERSION,  # NOQA: N806
            PATH_TO_PROJECT,  # NOQA: N806
            AUTHOR_NAME,  # NOQA: N806
        ) = (
            _application_title.strip(),
            _project_name.strip(),
            _application_version.strip(),
            _path_to_project.strip(),
            _author_name.strip(),
        )

        if (
            len(APPLICATION_TITLE)
            and len(PROJECT_NAME)
            and len(APPLICATION_VERSION)
            and len(PATH_TO_PROJECT)
            and len(AUTHOR_NAME)
        ) == 0:
            return SweetAlert().fire(
                "Please Fill Up All the Fields!", type="warning"
            )

        chars = ""
        for char in list(self.ignore_chars):
            if char in PROJECT_NAME:
                chars += char

        if chars:
            return SweetAlert().fire(
                f"Please Don't Use '{chars}' in Project Name",
                type="warning",
            )
        else:
            for i in "1234567890":
                if PROJECT_NAME.startswith(i):
                    return SweetAlert().fire(
                        "Please Don't Use numbers as starting"
                        + "letters of the Project Name",
                        type="warning",
                    )

        FULL_PATH_TO_PROJECT = os.path.join(  # NOQA: N806
            PATH_TO_PROJECT, PROJECT_NAME
        )
        self.path_to_project = FULL_PATH_TO_PROJECT
        project_name = PROJECT_NAME.lower()

        if not os.path.exists(PATH_TO_PROJECT):
            return SweetAlert().fire(
                "Folder Path not Exists!",
                PATH_TO_PROJECT,
                type="warning",
            )

        if os.path.exists(FULL_PATH_TO_PROJECT):
            return SweetAlert().fire(
                f"Folder Named {project_name} is Already Exists! in '{PATH_TO_PROJECT}'",  # NOQA: E501
                type="warning",
            )

        utils.copytree(BASE_TEMPLATE_FOLDER, FULL_PATH_TO_PROJECT)

        os.rename(
            os.path.join(FULL_PATH_TO_PROJECT, "project_name.py"),
            os.path.join(FULL_PATH_TO_PROJECT, f"{project_name}.py"),
        )

        PROJECT_UIX_FOLDER = os.path.join(  # NOQA: N806
            FULL_PATH_TO_PROJECT, "libs", "uix"
        )

        for py_file in self.template_py_files:
            shutil.copy(
                py_file,
                os.path.join(PROJECT_UIX_FOLDER, "baseclass"),
            )
        for kv_file in self.template_kv_files:
            shutil.copy(
                kv_file,
                os.path.join(PROJECT_UIX_FOLDER, "kv"),
            )

        for file in utils.get_files(FULL_PATH_TO_PROJECT, [".py", ".spec"]):
            utils.edit_file(
                in_file=file,
                values={
                    "APPLICATION_TITLE": APPLICATION_TITLE,
                    "PROJECT_NAME": PROJECT_NAME,
                    "project_name": project_name,
                    "APPLICATION_VERSION": APPLICATION_VERSION,
                    "AUTHOR_NAME": AUTHOR_NAME,
                    "PRIMARY_PALETTE": self.ids.primary.ids.primary_palette.current_item,  # NOQA: E501
                    "PRIMARY_HUE": self.ids.primary.ids.primary_hue.current_item,  # NOQA: E501
                    "ACCENT_PALETTE": self.ids.accent.ids.accent_palette.current_item,  # NOQA: E501
                    "ACCENT_HUE": self.ids.accent.ids.accent_hue.current_item,
                    "THEME_STYLE": self.ids.theme_style.ids.theme_style.current_item,  # NOQA: E501
                },
            )

        with open(os.path.join(TEMPLATES_FOLDER, "classes.json")) as f:
            data = json.loads(f.read())

        utils.edit_file(
            in_file=os.path.join(FULL_PATH_TO_PROJECT, "hotreloader.py"),
            values={
                "CLASSES": f"CLASSES = {str(data[self.selected_template])}"
            },
        )

        if self.ids.gitignore.active:
            shutil.copy(
                os.path.join(MISC_FOLDER, ".gitignore"),
                FULL_PATH_TO_PROJECT,
            )
        if self.ids.readme.active:
            self.edit_misc_file("README.md", {"PROJECT_NAME": PROJECT_NAME})
        if self.ids.license.active:
            self.edit_misc_file(
                "LICENSE",
                {
                    "YEAR": str(datetime.now().year),
                    "COPYRIGHT_HOLDER": AUTHOR_NAME,
                },
            )

        SweetAlert().fire(
            "Congrat's",
            f"Project '{PROJECT_NAME}' Has Been Created Successfully!",
            type="success",
        )
Example #17
0
class WalletBox(MDGridLayout):
    cols = 2
    text = StringProperty()

    wallet_alert_dialog = None
    delete_wallet_alert_dialog = None

    FONT_PATH = f"{os.environ['DECENTRA_ROOT']}/gui_lib/fonts/"

    def reflesh_balance(self):

        self.text = "Balance: " + str(
            GetBalance(Wallet_Import(-1, 0), GetBlock()))

    def show_wallet_alert_dialog(self):
        if not self.wallet_alert_dialog:
            self.wallet_alert_dialog = SweetAlert(
                title="Creating a wallet",
                type="custom",
                auto_dismiss=False,
                content_cls=Create_Wallet_Box(),
                buttons=[
                    MDFlatButton(
                        text="CANCEL",
                        on_press=self.dismiss_wallet_alert_dialog,
                        font_size="18sp",
                        font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                    MDFlatButton(text="OK",
                                 font_size="18sp",
                                 font_name=self.FONT_PATH +
                                 "RobotoCondensed-Bold",
                                 on_press=self.create_the_wallet)
                ],
            )
        self.wallet_alert_dialog.open()

    def callback_for_menu_items(self, *args):
        if not args[0] == the_settings()["wallet"]:
            change_wallet(int(args[0]))
            self.reflesh_balance()
        Clipboard.copy(Wallet_Import(int(args[0]), 3))
        SweetAlert().fire(
            "The address has been copied to your clipboard.",
            type='success',
        )

    def show_example_list_bottom_sheet(self):
        bottom_sheet_menu = MDListBottomSheet(radius=25, radius_from="top")
        data = {}
        all_wallets = list(get_saved_wallet())

        current_wallet = the_settings()["wallet"]
        for wallet in all_wallets:
            number = all_wallets.index(wallet)
            address = Wallet_Import(all_wallets.index(wallet), 3)
            if not current_wallet == number:
                data[number] = address
            else:
                data[number] = address + " - CURRENTLY USED"

        for item in data.items():
            bottom_sheet_menu.add_item(
                str(item[0]) + " : " + item[1],
                lambda x, y=item[0]: self.callback_for_menu_items(y),
            )
        bottom_sheet_menu.open()

    def dismiss_wallet_alert_dialog(self, widget):
        self.wallet_alert_dialog.dismiss()

    def create_the_wallet(self, widget):
        text_list = []
        for obj in self.wallet_alert_dialog.content_cls.children:
            for sub_obj in obj.children:
                Wallet_Create(sub_obj.text)
                self.dismiss_wallet_alert_dialog(widget)

                sub_obj.text = ""

    def Wallet_Create(self):
        self.show_wallet_alert_dialog()

    def dismiss_delete_wallet_alert_dialog(self, widget):
        self.delete_wallet_alert_dialog.dismiss()

    def show_delete_wallet_alert_dialog(self):
        if not self.delete_wallet_alert_dialog:
            self.delete_wallet_alert_dialog = SweetAlert(
                title="Deleting a wallet",
                type="custom",
                auto_dismiss=False,
                content_cls=Delete_Wallet_Box(),
                buttons=[
                    MDFlatButton(
                        text="CANCEL",
                        on_press=self.dismiss_delete_wallet_alert_dialog,
                        font_size="18sp",
                        font_name=self.FONT_PATH + "RobotoCondensed-Bold",
                    ),
                    MDFlatButton(text="OK",
                                 font_size="18sp",
                                 font_name=self.FONT_PATH +
                                 "RobotoCondensed-Bold",
                                 on_press=self.delete_the_wallet)
                ],
            )
        self.delete_wallet_alert_dialog.open()

    def Wallet_Delete(self):
        if not the_settings()["wallet"] == 0:
            self.show_delete_wallet_alert_dialog()
        else:
            SweetAlert().fire(
                "First wallet cannot be deleted.",
                type='failure',
            )

    def delete_the_wallet(self, widget):
        saved_wallets = get_saved_wallet()
        selected_wallet_pubkey = Wallet_Import(int(the_settings()["wallet"]),
                                               0)
        for each_wallet in saved_wallets:
            if selected_wallet_pubkey == saved_wallets[each_wallet][
                    "publickey"]:
                change_wallet(0)
                Wallet_Delete(each_wallet)
                self.reflesh_balance()
                self.dismiss_delete_wallet_alert_dialog(widget)