File size: 968 Bytes
adff838
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import streamlit as st
import encdec
import shutil


def clear():
    passowrd = st.text_input("Enter a password", type="password")
    clearbtn = st.button("clear")
    known = os.path.join(os.path.dirname(os.path.abspath(__file__)), "known_user")
    unknown = os.path.join(os.path.dirname(os.path.abspath(__file__)), "unknown_user")
    db = os.path.join(os.path.dirname(os.path.abspath(__file__)), "db.sqlite")
    if clearbtn and passowrd == encdec.encdec():
        try:
            if os.path.exists(known):
                shutil.rmtree(known)
                os.makedirs(known)
            if os.path.exists(unknown):
                shutil.rmtree(unknown)
                os.makedirs(unknown)
            if os.path.exists(db):
                os.remove(db)
            st.success("Cleared")
        except Exception as e:
            st.error(e)
    if clearbtn and passowrd != encdec.encdec():
        st.error("Password entered is incorrect")