diff --git a/.gitignore b/.gitignore index 48c0738..3094f5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /python.nja +*.pyc diff --git a/Internet/Info_IP.py b/Internet/Info_IP.py new file mode 100644 index 0000000..412b813 --- /dev/null +++ b/Internet/Info_IP.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# -*- encoding: utf-8 -*- + +####################################### +# ### Raúl Caro Pastorino ### # +## ## ## ## +### # https://github.com/fryntiz/ # ### +## ## ## ## +# ### www.fryntiz.es ### # +####################################### + +# Función para obtener información sobre una IP pasada como parámetro +# En caso de no recibir una IP tomará nuestra IP pública +# Se depende del paquete "geoiplookup" en el sistema operativo + +############################## +## LIBRERÍAS ## +############################## +import commands + +def getPais(IP): + + # Extraer cadena con el pais + pais = commands.getoutput("geoiplookup " + str(IP)) + + # Limpiar País + pais = pais.split('\n')[0].split(': ')[1] + + # Si no está instalado el programa "geoiplookup" + if pais == "sh: geoiplookup: not found": + print("Necesitas instalar geoiplookup para poder continuar") + pais = '' + #Cuando ocurre un error o extrae cadena no válida + elif len(str(pais)) > 200: + print("No ha sido posible conseguir el país para la IP → " + str(IP)) + pais = '' + + # Devuelve el país o la cadena vacía + return pais + +print getPais('8.8.8.8') diff --git a/Sistema/Informacion_Sistema.py b/Sistema/Informacion_Sistema.py new file mode 100644 index 0000000..5222d1d --- /dev/null +++ b/Sistema/Informacion_Sistema.py @@ -0,0 +1,59 @@ +#!/usr/bin/python +# -*- encoding: utf-8 -*- + +####################################### +# ### Raúl Caro Pastorino ### # +## ## ## ## +### # https://github.com/fryntiz/ # ### +## ## ## ## +# ### www.fryntiz.es ### # +####################################### + +# Script que contiene una clase, la cual al instanciarla creará +# un objeto con todos los datos del sistema que estamos usando +# de forma que será accesible desde fuera +# Sistema operativo → Linux + +############################## +## LIBRERÍAS ## +############################## +import os +import datetime + + +class info(): + + # Obtener nombre para el usuario actual + def getUser(self): + user = os.getlogin() + return user + + # Obtener nombre del Equipo + def getSysName(self): + sysName = os.uname()[1] + return sysName + + # Obtener tipo del Sistema Operativo + def getSysType(self): + sysType = os.uname()[0] + return sysType + + # Obtener Versión del Kernel + def getSysKernel(self): + sysKernel = os.uname()[2] + return sysKernel + + # Obtener Nombre del sistema Operativo, Kernel y fecha de actualización + def getSysInfo(self): + sysInfo = os.uname()[3] + return sysInfo + + # Obtener arquitectura del Sistema Operativo + def getSysArch(self): + sysArch = os.uname()[4] + return sysArch + + # Obtener Fecha y Hora actual en el sistema + def getFullDate(self): + fecha = datetime.datetime.today() + return fecha diff --git a/python.nja b/python.nja deleted file mode 100644 index b874d0e..0000000 --- a/python.nja +++ /dev/null @@ -1,29 +0,0 @@ -{ - "mainFile": "", - "use-tabs": true, - "venv": "", - "relatedProjects": [], - "name": "Python", - "license": "GNU General Public License v3", - "url": "", - "pythonPath": "python", - "preExecScript": "", - "additional_builtins": [], - "programParams": "", - "indentation": 4, - "PYTHONPATH": "", - "supported-extensions": [ - ".py", - ".html", - ".jpg", - ".png", - ".ui", - ".css", - ".json", - ".js", - ".ini" - ], - "project-type": "", - "postExecScript": "", - "description": "" -} \ No newline at end of file