-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathemaildbmod.py
executable file
·101 lines (76 loc) · 2.58 KB
/
emaildbmod.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*- coding: utf-8 -*-
"""
fertilizer UI setting storage utilities
"""
from __future__ import print_function
import logging
import os
import os.path
import sys
import string
from datetime import datetime,date,timedelta
import time
import filestoragemod
import hardwaremod
# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////
global DATAFILENAME
DATAFILENAME="emailcred.txt"
# if file does not exist create file
data=[]
if not filestoragemod.readfiledata(DATAFILENAME,data): #read setting file
filedata=[{'name':'email', 'address':'','password':'' }]
filestoragemod.savefiledata(DATAFILENAME,filedata)
def savedata(filedata):
filestoragemod.savefiledata(DATAFILENAME,filedata)
def getelementlist():
recordkey=hardwaremod.HW_FUNC_USEDFOR
recordvalue="mailcontrol"
keytosearch=hardwaremod.HW_INFO_NAME
datalist=hardwaremod.searchdatalist(recordkey,recordvalue,keytosearch)
#print "elementlist= ",datalist
return datalist
def getaddress():
recordkey="name"
recordvalue="email"
keytosearch="address"
dataitem=filestoragemod.searchdata(DATAFILENAME,recordkey,recordvalue,keytosearch)
return dataitem
def getpassword():
recordkey="name"
recordvalue="email"
keytosearch="password"
dataitem=filestoragemod.searchdata(DATAFILENAME,recordkey,recordvalue,keytosearch)
return dataitem
def changesavesetting(FTparameter,FTvalue):
searchfield="name"
searchvalue="email"
isok=filestoragemod.savechange(DATAFILENAME,searchfield,searchvalue,FTparameter,FTvalue)
if not isok:
print("problem saving paramete")
return isok
def restoredefault():
filestoragemod.deletefile(DATAFILENAME)
filedata=[{'name':'email', 'address':'','password':'' }]
filestoragemod.savefiledata(DATAFILENAME,filedata)
def get_path():
'''Get the path to this script no matter how it's run.'''
#Determine if the application is a py/pyw or a frozen exe.
if hasattr(sys, 'frozen'):
# If run from exe
dir_path = os.path.dirname(sys.executable)
elif '__file__' in locals():
# If run from py
dir_path = os.path.dirname(__file__)
else:
# If run from command line
dir_path = sys.path[0]
return dir_path
#--end --------////////////////////////////////////////////////////////////////////////////////////
if __name__ == '__main__':
# comment
address="[email protected]"
password="haha"
changesavesetting("address",address)
changesavesetting("password",password)
print(getaddress())
print(getpassword())