-
Notifications
You must be signed in to change notification settings - Fork 37
/
clockdbmod.py
executable file
·84 lines (59 loc) · 2.03 KB
/
clockdbmod.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
# -*- 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
# ///////////////// -- GLOBAL VARIABLES AND INIZIALIZATION --- //////////////////////////////////////////
global DATAFILENAME
DATAFILENAME="clocktimezone.txt"
# if file does not exist create file
data=[]
if not filestoragemod.readfiledata(DATAFILENAME,data): #read setting file
filedata=[{'name':'clock', 'timezone':'UTC'}]
filestoragemod.savefiledata(DATAFILENAME,filedata)
def savedata(filedata):
filestoragemod.savefiledata(DATAFILENAME,filedata)
def gettimezone():
recordkey="name"
recordvalue="clock"
keytosearch="timezone"
dataitem=filestoragemod.searchdata(DATAFILENAME,recordkey,recordvalue,keytosearch)
return dataitem
def changesavesetting(FTparameter,FTvalue):
searchfield="name"
searchvalue="clock"
isok=filestoragemod.savechange(DATAFILENAME,searchfield,searchvalue,FTparameter,FTvalue)
if not isok:
print("problem saving paramete")
return isok
def restoredefault():
filestoragemod.deletefile(DATAFILENAME)
filedata=[{'name':'clock', 'timezone':'UTC'}]
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
timezone="Europe/Rome"
changesavesetting("timezone",timezone)
print(gettimezone())