changes and fixes

Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
Omar Sánchez Pizarro
2023-05-25 11:35:05 +02:00
parent 73dc43a193
commit 76cf03f883

View File

@@ -53,7 +53,7 @@ optionalArgs.add_argument('-ga', '--geoAccuracy', help="GEO Accuracy", type=floa
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")
exit(20)
@@ -114,6 +114,9 @@ class AutoFicher():
def updateTime(self):
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):
self.updateTime()
return self.get('version', self.headers)
@@ -123,6 +126,7 @@ class AutoFicher():
def sendUpdate(self):
self.updateTime()
self.updateVersion()
calendar = self.calendarCheck()
if calendar:
@@ -166,6 +170,10 @@ class AutoFicher():
self.sendReport('Corriendo en modo debug. No se realizará ninguna acción')
exit(20)
if response.text == "no valid worker":
self.sendReport("El trabajador no ha podido ser identificado")
exit(20)
try:
rj = json.loads(response.text)
except:
@@ -243,7 +251,7 @@ class AutoFicher():
if datetime.fromisoformat(start).timestamp() <= datetime.now().timestamp() <= datetime.fromisoformat(end).timestamp():
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']:
return event['summary']
@@ -251,7 +259,7 @@ class AutoFicher():
print(f'An error occurred: {error}')
return 'Error de llamada a api'
return 'No se que ha pasado :/'
return False
if __name__ == '__main__':
af = AutoFicher()