def system_html(self): # now = datetime.datetime.now().strftime('%d.%m.%Y %H:%M') now = self.plugin.shtime.now().strftime('%d.%m.%Y %H:%M') system = platform.system() vers = platform.version() # node = platform.node() node = socket.getfqdn() arch = platform.machine() user = pwd.getpwuid(os.geteuid()).pw_name # os.getlogin() ip = Utils.get_local_ipv4_address() ipv6 = Utils.get_local_ipv6_address() space = os.statvfs(self._sh_dir) freespace = space.f_frsize * space.f_bavail / 1024 / 1024 # return host uptime uptime = time.mktime(datetime.datetime.now().timetuple()) - psutil.boot_time() days = uptime // (24 * 3600) uptime = uptime % (24 * 3600) hours = uptime // 3600 uptime %= 3600 minutes = uptime // 60 uptime %= 60 seconds = uptime uptime = self.age_to_string(days, hours, minutes, seconds) # return SmarthomeNG runtime rt = str(self._sh.runtime()) daytest = rt.split(' ') if len(daytest) == 3: days = int(daytest[0]) hours, minutes, seconds = [float(val) for val in str(daytest[2]).split(':')] else: days = 0 hours, minutes, seconds = [float(val) for val in str(daytest[0]).split(':')] sh_uptime = self.age_to_string(days, hours, minutes, seconds) pyversion = "{0}.{1}.{2} {3}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.version_info[3]) #python_packages = self.getpackages() #req_dict = self.get_requirements_info() return self.render_template('system.html', now=now, system=system, sh_vers=shngversion.get_shng_version(), sh_desc=shngversion.get_shng_description(), plg_vers=shngversion.get_plugins_version(), plg_desc=shngversion.get_plugins_description(), sh_dir=self._sh_dir, vers=vers, node=node, arch=arch, user=user, freespace=freespace, uptime=uptime, sh_uptime=sh_uptime, pyversion=pyversion, ip=ip, ipv6=ipv6)
def systeminfo_json(self): """ Return System inforation as json ( for Angular tests only) :return: """ # now = datetime.datetime.now().strftime('%d.%m.%Y %H:%M') now = str(self.module.shtime.now()) system = platform.system() self.read_linuxinfo() vers = Utils.strip_quotes(self.os_release.get('PRETTY_NAME', '')) if vers == '': vers = platform.version() arch = platform.machine() # node = platform.node() node = socket.getfqdn() user = pwd.getpwuid(os.geteuid()).pw_name # os.getlogin() ipv6 = Utils.get_local_ipv6_address() ip = Utils.get_local_ipv4_address() space = os.statvfs(self._sh.base_dir) freespace = space.f_frsize * space.f_bavail / 1024 / 1024 rt = Shtime.get_instance().runtime_as_dict() sh_runtime_seconds = rt['total_seconds'] pyversion = "{0}.{1}.{2} {3}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.version_info[3]) response = {} response['now'] = now response['ostype'] = self.get_ostype() response['system'] = system response['sh_vers'] = shngversion.get_shng_version() response['sh_desc'] = shngversion.get_shng_description() response['plg_vers'] = shngversion.get_plugins_version() response['plg_desc'] = shngversion.get_plugins_description() response['sh_dir'] = self._sh.base_dir response['vers'] = vers response['node'] = node response['arch'] = arch response['user'] = user response['freespace'] = freespace response['hardware'] = self.get_rasppi_info() if response['hardware'] == '': response['hardware'] = self.cpu_info.get('brand_raw', '') response['rasppi'] = self.running_on_rasppi() response['uptime'] = time.mktime(datetime.datetime.now().timetuple()) - psutil.boot_time() response['sh_uptime'] = sh_runtime_seconds response['pyversion'] = pyversion response['pypath'] = self._sh.python_bin response['ip'] = ip response['ipv6'] = ipv6 response['pid'] = str(lib.daemon.read_pidfile(self._sh._pidfile)) self.logger.warning("admin: systeminfo_json: response = {}".format(response)) return json.dumps(response)
def system_json(self): """ Return System inforation as json ( for Angular tests only) :return: """ # now = datetime.datetime.now().strftime('%d.%m.%Y %H:%M') now = self.plugin.shtime.now().strftime('%d.%m.%Y %H:%M') system = platform.system() vers = platform.version() # node = platform.node() node = socket.getfqdn() arch = platform.machine() user = pwd.getpwuid(os.geteuid()).pw_name # os.getlogin() ip = Utils.get_local_ipv4_address() ipv6 = Utils.get_local_ipv6_address() space = os.statvfs(self._sh_dir) freespace = space.f_frsize * space.f_bavail / 1024 / 1024 # return host uptime uptime = time.mktime( datetime.datetime.now().timetuple()) - psutil.boot_time() days = uptime // (24 * 3600) uptime = uptime % (24 * 3600) hours = uptime // 3600 uptime %= 3600 minutes = uptime // 60 uptime %= 60 seconds = uptime uptime = self.age_to_string(days, hours, minutes, seconds) # return SmarthomeNG runtime rt = str(Shtime.get_instance().runtime()) daytest = rt.split(' ') if len(daytest) == 3: days = int(daytest[0]) hours, minutes, seconds = [ float(val) for val in str(daytest[2]).split(':') ] else: days = 0 hours, minutes, seconds = [ float(val) for val in str(daytest[0]).split(':') ] sh_uptime = self.age_to_string(days, hours, minutes, seconds) pyversion = "{0}.{1}.{2} {3}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.version_info[3]) #python_packages = self.getpackages() #req_dict = self.get_requirements_info() response = {} response['now'] = now response['system'] = system response['sh_vers'] = shngversion.get_shng_version() response['sh_desc'] = shngversion.get_shng_description() response['plg_vers'] = shngversion.get_plugins_version() response['plg_desc'] = shngversion.get_plugins_description() response['sh_dir'] = self._sh_dir response['vers'] = vers response['node'] = node response['arch'] = arch response['user'] = user response['freespace'] = freespace response['uptime'] = uptime response['sh_uptime'] = sh_uptime response['pyversion'] = pyversion response['ip'] = ip response['ipv6'] = ipv6 return json.dumps(response)
def systeminfo_json(self): """ Return System inforation as json ( for Angular tests only) :return: """ # now = datetime.datetime.now().strftime('%d.%m.%Y %H:%M') now = str(self.module.shtime.now()) system = platform.system() vers = platform.version() # node = platform.node() node = socket.getfqdn() arch = platform.machine() user = pwd.getpwuid(os.geteuid()).pw_name # os.getlogin() # ipv6 = Utils.get_local_ipv6_address() ip = Utils.get_local_ipv4_address() ipv6 = '' space = os.statvfs(self._sh.base_dir) freespace = space.f_frsize * space.f_bavail / 1024 / 1024 # rt = str(self.module.shtime.runtime()) # daytest = rt.split(' ') # if len(daytest) == 3: # days = int(daytest[0]) # hours, minutes, seconds = [float(val) for val in str(daytest[2]).split(':')] # else: # days = 0 # hours, minutes, seconds = [float(val) for val in str(daytest[0]).split(':')] # sh_runtime_seconds = days * 24 * 3600 + hours * 3600 + minutes * 60 + seconds rt = Shtime.get_instance().runtime_as_dict() sh_runtime_seconds = rt['total_seconds'] pyversion = "{0}.{1}.{2} {3}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.version_info[3]) response = {} response['now'] = now response['system'] = system response['sh_vers'] = shngversion.get_shng_version() response['sh_desc'] = shngversion.get_shng_description() response['plg_vers'] = shngversion.get_plugins_version() response['plg_desc'] = shngversion.get_plugins_description() response['sh_dir'] = self._sh.base_dir response['vers'] = vers response['node'] = node response['arch'] = arch response['user'] = user response['freespace'] = freespace response['uptime'] = time.mktime( datetime.datetime.now().timetuple()) - psutil.boot_time() response['sh_uptime'] = sh_runtime_seconds response['pyversion'] = pyversion response['ip'] = ip response['ipv6'] = ipv6 self.logger.debug( "admin: systeminfo_json: response = {}".format(response)) return json.dumps(response)