particionado

This commit is contained in:
Omar Sánchez Pizarro
2023-10-09 14:13:36 +02:00
parent 927c281631
commit d09c66b125
4711 changed files with 2368269 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -9,7 +9,7 @@ class ArgParser:
self.parser._action_groups.pop()
obligatoryArgs = self.parser.add_argument_group("Argumentos obligatorios")
obligatoryArgs.add_argument('-p', '--pin', help="Contraseña", type=int, required=True)
obligatoryArgs.add_argument('-p', '--pin', help="Contraseña", type=int)
obligatoryArgs.add_argument('-t', '--type', help="Tipo marcado. 0 = Entrada, 1 = Salida", type=int)
optionalArgs = self.parser.add_argument_group("Argumentos opcionales")

View File

@@ -54,6 +54,8 @@ class GoogleCalendar:
def buildService(self):
self.service = build('calendar', 'v3', credentials=self.creds)
# self.service.calendars().get(calendarId='e51d3bfb6b352c48afb8bd7a5d494599cc3eaa686800a856796306f50c6d72fd@group.calendar.google.com')
# self.service.create_notification_channel()
def getNow(self):
return datetime.utcnow().strftime('%Y-%m-%dT00:00:00Z')

View File

@@ -11,5 +11,4 @@ class telegramBot:
self.bot = telegram.Bot(token=config['telegram']['token'])
def sendMessage(self, message):
print(message)
self.bot.sendMessage(chat_id=config['telegram']['chat_id'], text=str(message))
self.bot.sendMessage(chat_id=config['telegram']['chat_id'], text=str(message), parse_mode=telegram.ParseMode.HTML)

View File

@@ -8,6 +8,7 @@ config = config_parser.ConfigParser().loadConfig()
class timenetManager:
telegram = None
message_acumulator = ""
def __init__(self):
self.telegram = telegram_bot.telegramBot()
@@ -30,8 +31,12 @@ class timenetManager:
furl = config['api_url'] + "v1/" + url
return requests.post(furl, data=data, headers=headers)
def sendReport(self, message):
self.telegram.sendMessage(message)
def addMessage(self, message):
print(message)
self.message_acumulator += message + "\n"
def sendReport(self):
self.telegram.sendMessage(self.message_acumulator)
def updateTime(self):
self.headers["tn-d"] = "\"" + datetime.now().astimezone(pytz.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") + "\""
@@ -51,10 +56,14 @@ class timenetManager:
def sendUpdate(self):
self.updateTime()
if args.pin is None:
# if pin is None, prompt for it
self.args.pin = int(input("Introduzca su pin: "))
calendar = google_calendar.GoogleCalendar()
calendar = calendar.getEvent()
if calendar:
self.sendReport("🟥🕐 Comprobación de calendario: " + calendar)
self.addMessage("🟥🕐 Comprobación de calendario: " + calendar)
return
typ = 0
@@ -70,7 +79,7 @@ class timenetManager:
elif hour in hOUT:
typ = 1
else:
self.sendReport("No se ha fichado ni desfichado ya que estamos en horario laboral, fuerze el estado con el parametro --type <0 = Entrada, 1 = Salida>")
self.addMessage("No se ha fichado ni desfichado ya que estamos en horario laboral, fuerze el estado con el parametro --type <0 = Entrada, 1 = Salida>")
else:
typ = args.type
@@ -88,27 +97,27 @@ class timenetManager:
response = None
if not args.debug:
self.sendReport("####HACIENDO CHECK####")
self.addMessage("####HACIENDO CHECK####")
response = self.post("check", data, self.headers)
else:
self.sendReport('Corriendo en modo debug. No se realizará ninguna acción')
self.addMessage('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")
self.addMessage("El trabajador no ha podido ser identificado")
exit(20)
try:
rj = json.loads(response.text)
except:
self.sendReport("La respuesta al hacer check no es correcta... algo ha pasado :/")
self.addMessage("La respuesta al hacer check no es correcta... algo ha pasado :/")
exit(20)
if response.status_code == 200:
if rj['Repeated']:
time = datetime.strptime(rj['RepeatedTime'], "%Y-%m-%dT%H:%M:%SZ").replace(
tzinfo=pytz.utc).astimezone(pytz.timezone("Europe/Madrid")).strftime("%H:%M")
self.sendReport("🕐 Ya se ha realizado este marcaje antes a las %s" % time)
self.addMessage("🕐 Ya se ha realizado este marcaje antes a las %s" % time)
else:
time = datetime.now().astimezone(pytz.timezone("Europe/Madrid")).strftime("%H:%M")
@@ -119,6 +128,8 @@ class timenetManager:
"text": "desfichado",
"emoji": "🏡🏃‍♂️🏢🕐"
}]
self.sendReport('%s Has %s correctamente a las %s' % (conditional_response[int(typ)]['emoji'], conditional_response[int(typ)]['text'], time))
self.addMessage('%s Has %s correctamente a las %s' % (conditional_response[int(typ)]['emoji'], conditional_response[int(typ)]['text'], time))
else:
self.sendReport("🟥🕐 No se ha podido fichar, la web no ha devuelto 200 OK")
self.addMessage("🟥🕐 No se ha podido fichar, la web no ha devuelto 200 OK")
self.sendReport()