def remove(self): ### remove files ### shell_exec('sudo rm {0} {1}'.format( self.getFile("bundle").getLocal(), self.getFile("md5sum").getLocal()))
def remove(self): ### remove files ### shell_exec('sudo rm {0}'.format(self.getFile("boot").getLocal()))
def bluetooth_status(): result = shell_exec('sudo sh ' + BASH_PATH + 'bluetooth.sh -a "status"') return json.loads(''.join(result))
def enable_bluetooth(): result = shell_exec('sudo sh ' + BASH_PATH + 'bluetooth.sh -a "enable"') return json.loads(''.join(result))
def main(): config = ConfigService() gcs = GCodeServiceClient() data = {} # Memory with open('/proc/meminfo', 'r') as f: meminfo = f.read().split() data['mem_total'] = int(meminfo[1]) data['mem_free'] = int(meminfo[4]) data['mem_used_percentage'] = int( (data['mem_free'] * 100.0) / data['mem_total']) # Board Temperature with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f: tmp = float(f.read()) data['temp'] = tmp / 1000.0 # Uptime with open('/proc/uptime', 'r') as f: tmp = f.read().split() data['time_alive'] = round(float(tmp[0])) # BCM2709 RPi2/RPi3 # BCM2708 RPi1 # Raspberry Pi version #soc_id = shell_exec('</proc/cpuinfo grep Hardware | awk \'{print $3}\'')[0].strip() #name_id = '' #soc_name = {'BCM2708' : 'Raspberry Pi Model B', 'BCM2709' : 'Raspberry Pi 3 Model B' } #if soc_id in soc_name: # data['rpi_version'] = soc_name[soc_id] #else: # data['rpi_version'] = soc_id data['rpi_version'] = rpi_version() # Storage tmp = shell_exec('df -Ph') table_header = tmp[0].split()[:-1] table_rows = [] visible_partitions = [ '/tmp', '/mnt/bigtemp', '/mnt/userdata', '/mnt/live/mnt/changes', '/mnt/live/mnt/bundles', '/mnt/live/mnt/boot' ] for row in tmp[1:]: tmp2 = row.split() if tmp2[5] in visible_partitions: table_rows.append(" ".join(tmp2)) data['table_header'] = table_header data['table_rows'] = table_rows # OS Info data['os_info'] = shell_exec('uname -a')[0].strip() # Fabtotum info #reply = gcs.send('M765') #fw = reply[0].split()[1] #reply = gcs.send('M763') #hw = reply[0] #data['fabtotum_info'] = {'fw':fw, 'hw':hw} # FABUI version ##db = Database(config) #fabui_version = SysConfig(db) #fabui_version.query_by('key', 'fabui_version') #data['fabui_version'] = fabui_version['text'] data['unit_configs'] = config.settings network_json_info = open(config.get('general', 'network_info_file')) network_info = json.load(network_json_info) data['eth_bytes'] = get_rx_tx_bytes('eth0') if 'wlan0' in network_info['interfaces']: data['wlan_bytes'] = get_rx_tx_bytes('wlan0') print json.dumps(data)