psutil already have boot_time function, no need in separate module

This commit is contained in:
Oleksii Shevchuk 2017-03-13 23:19:43 +02:00
parent 6d67250c38
commit 427defea99
3 changed files with 25 additions and 9 deletions

View File

@ -250,7 +250,7 @@ __EOF__
python -OO -m pip install six packaging appdirs
python -OO -m pip install \
rpyc pycrypto pyaml rsa netaddr tinyec pyyaml ecdsa \
paramiko uptime pylzma pydbus python-ptrace psutil scandir \
paramiko pylzma pydbus python-ptrace psutil scandir \
scapy colorama pyOpenSSL \
--upgrade --no-binary :all:
@ -472,7 +472,7 @@ make install
python -OO -m pip install six packaging appdirs
python -OO -m pip install \
rpyc pycrypto pyaml rsa netaddr tinyec pyyaml ecdsa \
paramiko uptime pylzma pydbus python-ptrace psutil scandir \
paramiko pylzma pydbus python-ptrace psutil scandir \
scapy colorama pyOpenSSL \
--upgrade --no-binary :all:

View File

@ -16,8 +16,8 @@ PYTHONVC="https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-
# PYWIN32="http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20220/pywin32-220.win32-py2.7.exe"
# PYWIN64="http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20220/pywin32-220.win-amd64-py2.7.exe"
PACKAGES="rpyc pyaml rsa pefile image rsa netaddr win_inet_pton netaddr tinyec uptime pycrypto cryptography pypiwin32"
PACKAGES="$PACKAGES asyncoro mss pyaudio scapy pyOpenSSL colorama pyuv"
PACKAGES="rpyc pyaml rsa pefile image rsa netaddr win_inet_pton netaddr tinyec pycrypto cryptography pypiwin32"
PACKAGES="$PACKAGES mss pyaudio scapy pyOpenSSL colorama pyuv"
BUILDENV=${1:-`pwd`/buildenv}

View File

@ -10,11 +10,11 @@ import time
import datetime
import platform
import uuid
import uptime
import urllib2
import urlparse
import StringIO
import socket
import psutil
def from_bytes(bytes):
return sum(ord(byte) * (256**i) for i, byte in enumerate(bytes))
@ -199,7 +199,7 @@ class SystemInfo(Command):
self.arch = arch or platform.machine()
self.node = node or uuid.getnode()
try:
self.boottime = boottime or uptime.boottime()
self.boottime = boottime or psutil.boot_time()
except:
self.boottime = datetime.datetime.fromtimestamp(0)
@ -256,9 +256,25 @@ class SystemInfo(Command):
archid = (block >> 1) & 7
internet = bool(block & 1)
node = from_bytes(node)
ip, boottime = struct.unpack('>II', rest)
boottime = datetime.datetime.fromtimestamp(boottime)
ip = netaddr.IPAddress(ip)
ip = 0
boottime = 0
try:
ip, boottime = struct.unpack('>II', rest)
try:
boottime = datetime.datetime.fromtimestamp(boottime)
except:
pass
try:
ip = netaddr.IPAddress(ip)
except:
pass
except:
pass
return SystemInfo(
system=SystemInfo.well_known_os_names_decode[osid],