@@ -47,44 +47,45 @@ def getConfig():
47
47
48
48
lat = lon = method = fajr_azaan_vol = default_azaan_vol = surahBaqarah = surahVolume = None
49
49
50
- # Get mandatory data
50
+ # Get mandatory data. First check args, if not present check settings.ini
51
51
try :
52
- lat = float (config ['DEFAULT' ]['lat' ])
53
- lon = float (config ['DEFAULT' ]['lon' ])
54
- method = config ['DEFAULT' ]['method' ]
55
- except KeyError :
56
- try :
57
- if args .lat :
58
- lat = float (args .lat )
59
- config ['DEFAULT' ]['lat' ] = str (lat )
60
- if args .lon :
61
- lon = float (args .lon )
62
- config ['DEFAULT' ]['lon' ] = str (lon )
63
- if args .method :
64
- method = args .method
65
- config ['DEFAULT' ]['method' ] = method
66
- except Exception as e :
67
- print ("Incorrect value or values not provided" )
68
- lat = lon = method = None
52
+ if args .lat :
53
+ lat = float (args .lat )
54
+ config ['DEFAULT' ]['lat' ] = str (lat )
55
+ else :
56
+ lat = float (config ['DEFAULT' ]['lat' ])
57
+
58
+ if args .lon :
59
+ lon = float (args .lon )
60
+ config ['DEFAULT' ]['lon' ] = str (lon )
61
+ else :
62
+ lon = float (config ['DEFAULT' ]['lon' ])
63
+
64
+ if args .method :
65
+ method = args .method
66
+ config ['DEFAULT' ]['method' ] = method
67
+ else :
68
+ method = config ['DEFAULT' ]['method' ]
69
+ except :
70
+ print ("Incorrect value or values not provided" )
71
+ lat = lon = method = None
72
+
69
73
70
74
# Get optional data
71
75
try :
72
- default_azaan_vol = int (config ['VOLUME' ]['defaultAzaanVolume' ])
73
- fajr_azaan_vol = int (config ['VOLUME' ]['fajrAzaanVolume' ])
74
- except KeyError as e :
75
- try :
76
- if args .default_azaan_vol :
77
- default_azaan_vol = int (args .default_azaan_vol )
78
- else :
79
- default_azaan_vol = 0
80
-
81
- if args .fajr_azaan_vol :
82
- fajr_azaan_vol = int (args .fajr_azaan_vol )
83
- else :
84
- fajr_azaan_vol = 0
85
- except :
86
- default_azaan_vol = 0
87
- fajr_azaan_vol = 0
76
+ if args .default_azaan_vol :
77
+ default_azaan_vol = int (args .default_azaan_vol )
78
+ else :
79
+ default_azaan_vol = int (config ['VOLUME' ]['defaultAzaanVolume' ])
80
+
81
+ if args .fajr_azaan_vol :
82
+ fajr_azaan_vol = int (args .fajr_azaan_vol )
83
+ else :
84
+ fajr_azaan_vol = int (config ['VOLUME' ]['fajrAzaanVolume' ])
85
+ except :
86
+ default_azaan_vol = 0
87
+ fajr_azaan_vol = 0
88
+
88
89
89
90
config ["VOLUME" ] = {
90
91
"defaultAzaanVolume" : str (default_azaan_vol ),
@@ -96,12 +97,13 @@ def getConfig():
96
97
try :
97
98
surahBaqarah = bool (config ['FRIDAY' ]['playSurahBaqarah' ])
98
99
surahVolume = int (config ['FRIDAY' ]['surahVolume' ])
99
- except KeyError as e :
100
- print (e )
100
+ except :
101
101
surahBaqarah = False
102
102
surahVolume = 0
103
103
config ["FRIDAY" ] = {"playSurahBaqarah" : str (surahBaqarah ), "surahVolume" : str (surahVolume )}
104
104
105
+
106
+ # If any of the mandatory values not provided or configures in settings.ini, exit and show usage
105
107
if not lat or not lon or not method :
106
108
print ("No values provided, please provide values as per below usage" )
107
109
parser .print_usage ()
@@ -178,7 +180,7 @@ def addClearLogsCronJob (objCronTab, strCommand):
178
180
print ("---------------------------------" )
179
181
print ("Co-ordinates provided" )
180
182
print ("---------------------------------" )
181
- print (f"Latitude: { lat } , Longitude: { lon } , Method: { method } " )
183
+ print (f"Latitude: { lat } \n Longitude: { lon } \n Method: { method } " )
182
184
print ("---------------------------------" )
183
185
print ()
184
186
print ("---------------------------------" )
0 commit comments