Ejemplo n.º 1
0
def startup():

    if not os.path.exists('master.txt'):
        pass_manager.first_time()
        db_manager.create_table()

    if pass_manager.check_master():
        print("----------You're in!----------")
        time.sleep(0.5)
        print("-" * 30)
        time.sleep(0.5)

        while True:

            show_menu()
            choice = input("Please enter your choice: ")
            print("\n")
            if choice == "1":
                pass_manager.add_password()
            elif choice == "2":
                pass_manager.update_password()
            elif choice == "3":
                pass_manager.retrieve_password()
            elif choice == "4":
                pass_manager.display_all()
            elif choice == "5":
                db_manager.close_db()
                break

    else:
        print("Your master password is not correct. Try Again. ")
Ejemplo n.º 2
0
def main():
    config = setup_config()
    links = []
    setup_logging()

    # Database configs
    hostname = config['harvester']['hostname']
    username = config['harvester']['username']
    password = config['harvester']['password']
    db.check_database(hostname, username, password)
    connection = db.database_connection(hostname, username, password,
                                        config['harvester']['port'],
                                        config['harvester']['database'])
    db.create_table(connection)

    base_url = config['main']['url']
    crawl(base_url, base_url, links, connection)
    db.close_connection(connection)
Ejemplo n.º 3
0
    print("Finished example inserts into database")


DBPATH = "health.db"
# Clear the database
remove_db(DBPATH)

# Test the DB manager to create a database
connection = dm.connect_db(DBPATH)

# Example columns:
col_names = ["patient_name", "time", "location", "activity"]
col_types = ["text", "real", "text", "text"]

dm.create_table(connection, "health", col_names, col_types)
insert_example_data(connection, "health")

dm.show_table(connection, "health")

# Now that the database has been created, we have to define the policies
# Your terms of use are defined by the functions that you are allowed to use
#  That way, you can control the downstream access as well by only giving access
#  to the functions that you can operate with

# data = dm.get_data(connection, "health")

print()

example1 = pc.policy2(connection)
print("\nEXAMPLE 1 QUERY: \n")
Ejemplo n.º 4
0
        mkdir(download_folder)

    # Connecting to the database (if the file doesn't
    #  exist it will be created)
    conn = dbm.create_connection("messages.db")

    # Checking if the table exist
    c = conn.cursor()

    c.execute(''' SELECT count(name) FROM sqlite_master
     WHERE type='table' AND name='id_to_file' ''')

    if c.fetchone()[0] == 0:
        # Create the table if it doesn't exist
        dbm.create_table(
            conn, '''CREATE TABLE id_to_file
         (Message_Id, File_Path)''')

    conn.commit()

    # Binding every command from settings.py with a function
    actions = {
        cmds[0]: download.download_all(client, conn),
        cmds[1]: download.download_all(client, conn, start_date=date.today()),
        cmds[2]: download.download_all(client, conn, media_type='image/png'),
        cmds[3]: download.download_all(client, conn, media_type='video/mp4'),
        cmds[4]: download.download_all(
            client,
            conn,
            media_type='audio/mpeg',
        )
Ejemplo n.º 5
0
    def user_input(self, file_name, file_path):
        #getting the file name
        print("Taking input")
        qid = QtGui.QInputDialog(self)
        db_manager.create_table(file_name)
        #inserting the file name and other details of the file into the database
        title = file_name
        label = "******************************************************file info*********************************************************"
        mode = QtGui.QLineEdit().Normal
        default = "Enter the file owner of objects"
        file_owner, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                    default)
        default = "Enter the file readers"
        file_readers, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                      default)
        default = "Enter the file writers"
        file_writers, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                      default)
        db_manager.dynamic_data_entry(file_name, "file", file_name, file_owner,
                                      file_readers, file_writers)

        #taking information about other objects
        label = "******************************************************Number of Objects*********************************************************"
        mode = QtGui.QLineEdit().Normal
        default = "Enter the number of objects"
        text, ok = QtGui.QInputDialog.getText(qid, title, label, mode, default)
        text = int(text)

        for i in range(text):

            title = file_name + " : Object" + " " + str(i)
            label = "Enter type of object\n2.global_vars \n3.function_name \n4.outputfile"
            default = "Object " + str(i) + " information "
            Type, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                  default)
            while Type == "":
                default = "Wrong Input!!!Enter again"
                Type, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                      default)

            label = "****************Enter name of object*********************"
            default = "Object " + str(i) + " information "
            Input, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                   default)
            while Input == "":
                default = "Wrong Input!!!Enter again"
                Input, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                       default)

            label = "************************Enter owner of object******************************"
            default = "Object " + str(i) + " information "
            Owner, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                   default)
            while Owner == "":
                default = "Wrong Input!!!Enter again"
                Owner, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                       default)

            label = "*************************Enter readers of object***************************"
            default = "Object " + str(i) + " information "
            Readers, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                     default)
            while Readers == "":
                default = "Wrong Input!!!Enter again"
                Readers, ok = QtGui.QInputDialog.getText(
                    qid, title, label, mode, default)

            label = "*************************Enter writers of object*****************************"
            default = "Object " + str(i) + " information "
            Writers, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                     default)
            while Input == "":
                default = "Wrong Input!!!Enter again"
                Input, ok = QtGui.QInputDialog.getText(qid, title, label, mode,
                                                       default)

            db_manager.dynamic_data_entry(file_name, Type, Input, Owner,
                                          Readers, Writers)
            print(Type + "    " + Input + "     " + Owner + ",{" + Readers +
                  "}, {" + Writers + "}\n")
        print("Input taken")
        self.show()
        print("Opening EDITOR....")
        self.editor()
        self.main(file_name, file_path)
Ejemplo n.º 6
0
    def __init__(self):
        super(Window, self).__init__()
        Window.setGeometry(self, 100, 100, 600, 300)
        self.setWindowTitle("PIFthon Monitor")
        self.setWindowIcon(QtGui.QIcon('./python_icon.png'))
        #main menu
        #general way to make main menu option dropdown
        #1.create the next four lines
        # extractAction = QtGui.QAction("&GET TO THE CHOPPAH",self)
        # extractAction.setShortcut("Ctrl+Q")
        # extractAction.setStatusTip('Leave The App')
        # extractAction.triggered.connect(self.close_application)
        #2.use self.statusBar
        #self.statusBar()
        #3.add it to the main menu object
        # mainMenu = self.menuBar()
        # fileMenu = mainMenu.addMenu('&File')
        #taking the file name from the user
        print("Opening Application")
        file_path = self.obtain_file_name()
        if "/" in file_path:
            length = len(file_path.split("/"))
            file_name = file_path.split("/")[length - 1]
        else:
            file_name = file_path
        #this only gives the program_name from program_name.py file
        file_name = file_name.rsplit('.', 1)[0]
        #the database corresponding to this program gets created in the DB Browser
        db_manager.create_table(file_name)

        #1.opening file
        openFile = QtGui.QAction('&Open File', self)
        openFile.setShortcut("Ctrl+O")
        openFile.setStatusTip("Open File")
        openFile.triggered.connect(self.file_open)

        ##saving file
        saveFile = QtGui.QAction('&Save File', self)
        saveFile.setShortcut("Ctrl+S")
        saveFile.setStatusTip("Save File")
        saveFile.triggered.connect(self.file_save)

        #close file
        extractAction = QtGui.QAction("&Close Application", self)
        extractAction.setShortcut("Ctrl+W")
        extractAction.setStatusTip('Leave The App')
        extractAction.triggered.connect(self.close_application)

        #open editor
        openEditor = QtGui.QAction('&Editor', self)
        openEditor.setShortcut("Ctrl+E")
        openEditor.setStatusTip("Open Editor")
        openEditor.triggered.connect(self.editor)

        self.statusBar()
        #taking mainMenu object
        mainMenu = self.menuBar()
        #adding file menu option to main menu bar
        fileMenu = mainMenu.addMenu('&File')

        fileMenu.addAction(openFile)
        fileMenu.addAction(saveFile)
        fileMenu.addAction(extractAction)

        #adding editor option to main menu bar
        editorMenu = mainMenu.addMenu('&Editor')
        editorMenu.addAction(openEditor)
        #setting user input dialog box
        #this function takes the input from the user and stores it in the database.
        self.user_input(file_name, file_path)