changes and fixes
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -53,7 +53,7 @@ optionalArgs.add_argument('-ga', '--geoAccuracy', help="GEO Accuracy", type=floa
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not args.type and not args.basedtime:
|
if args.type is None and args.basedtime is False:
|
||||||
print("Hay que indicar al menos un metodo de fichaje -t <0 o 1> o -bt")
|
print("Hay que indicar al menos un metodo de fichaje -t <0 o 1> o -bt")
|
||||||
exit(20)
|
exit(20)
|
||||||
|
|
||||||
@@ -114,6 +114,9 @@ class AutoFicher():
|
|||||||
def updateTime(self):
|
def updateTime(self):
|
||||||
self.headers["tn-d"] = "\"" + datetime.now().astimezone(pytz.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") + "\""
|
self.headers["tn-d"] = "\"" + datetime.now().astimezone(pytz.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") + "\""
|
||||||
|
|
||||||
|
def updateVersion(self):
|
||||||
|
self.headers["tn-v"] = self.getVersion()
|
||||||
|
|
||||||
def getVersion(self):
|
def getVersion(self):
|
||||||
self.updateTime()
|
self.updateTime()
|
||||||
return self.get('version', self.headers)
|
return self.get('version', self.headers)
|
||||||
@@ -123,6 +126,7 @@ class AutoFicher():
|
|||||||
|
|
||||||
def sendUpdate(self):
|
def sendUpdate(self):
|
||||||
self.updateTime()
|
self.updateTime()
|
||||||
|
self.updateVersion()
|
||||||
|
|
||||||
calendar = self.calendarCheck()
|
calendar = self.calendarCheck()
|
||||||
if calendar:
|
if calendar:
|
||||||
@@ -166,6 +170,10 @@ class AutoFicher():
|
|||||||
self.sendReport('Corriendo en modo debug. No se realizará ninguna acción')
|
self.sendReport('Corriendo en modo debug. No se realizará ninguna acción')
|
||||||
exit(20)
|
exit(20)
|
||||||
|
|
||||||
|
if response.text == "no valid worker":
|
||||||
|
self.sendReport("El trabajador no ha podido ser identificado")
|
||||||
|
exit(20)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rj = json.loads(response.text)
|
rj = json.loads(response.text)
|
||||||
except:
|
except:
|
||||||
@@ -243,7 +251,7 @@ class AutoFicher():
|
|||||||
|
|
||||||
if datetime.fromisoformat(start).timestamp() <= datetime.now().timestamp() <= datetime.fromisoformat(end).timestamp():
|
if datetime.fromisoformat(start).timestamp() <= datetime.now().timestamp() <= datetime.fromisoformat(end).timestamp():
|
||||||
if event['organizer']['displayName'] == 'autoficher':
|
if event['organizer']['displayName'] == 'autoficher':
|
||||||
return 'Forzado desde autoficher - ' + event['summary']
|
return 'Forzado desde autoficher - ' + event.get("summary", "Sin Título")
|
||||||
|
|
||||||
if 'description' in event and ("Cataluña" in event['description'] or 'Día festivo' in event['description']or 'Celebración\n' in event['description']) and not 'Cambio de horario' in event['summary']:
|
if 'description' in event and ("Cataluña" in event['description'] or 'Día festivo' in event['description']or 'Celebración\n' in event['description']) and not 'Cambio de horario' in event['summary']:
|
||||||
return event['summary']
|
return event['summary']
|
||||||
@@ -251,7 +259,7 @@ class AutoFicher():
|
|||||||
print(f'An error occurred: {error}')
|
print(f'An error occurred: {error}')
|
||||||
return 'Error de llamada a api'
|
return 'Error de llamada a api'
|
||||||
|
|
||||||
return 'No se que ha pasado :/'
|
return False
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
af = AutoFicher()
|
af = AutoFicher()
|
||||||
|
|||||||
Reference in New Issue
Block a user