forked from Hydrosys4/Master
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemaildbmod.py
executable file
·119 lines (99 loc) · 3.15 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- 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
restoredefault()
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 getserver():
recordkey="name"
recordvalue="email"
keytosearch="server"
dataitem=filestoragemod.searchdata(DATAFILENAME,recordkey,recordvalue,keytosearch)
# set default
if dataitem == "":
dataitem = "smtp.gmail.com"
return dataitem
def getport():
recordkey="name"
recordvalue="email"
keytosearch="port"
dataitem=filestoragemod.searchdata(DATAFILENAME,recordkey,recordvalue,keytosearch)
# set default
if dataitem == "":
dataitem = "587"
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':'', 'server': 'smtp.gmail.com', 'port': '587'}]
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="hello@mail.com"
password="haha"
server="smtp.gmail.com"
port="587"
#changesavesetting("address",address)
#changesavesetting("password",password)
#changesavesetting("server",server)
#changesavesetting("port",port)
#print(getaddress())
#print(getpassword())
print(getserver())
print(getport())