def get_pci_devices(self): try: devs = super(HostFromLogs, self).get_pci_devices() return devs except FileNotFound: # Fall back to looking for the file lspci-vv.out print "***lspci-nnm.out found. Falling back to looking for lspci-vv.out and lspci-n.out.***" lspci_vv_recs = parse_data(LspciVVParser, self._load_from_file('lspci-vv.out')) lspci_n_recs = parse_data(LspciNParser, self._load_from_file('lspci-n.out')) all_recs = lspci_vv_recs + lspci_n_recs recs = combine_recs(all_recs, 'pci_device_bus_id') return [PCIDevice(rec) for rec in recs]
def get_pci_devices(self): data = self.get_lspci_data() parser = LspciNNMMParser(data) devices = parser.parse_items() return [PCIDevice(device) for device in devices]
def __init__(self): self.window = Gtk.Window() self.window.set_resizable(False) self.window.set_size_request(520, 550) self.window.set_title("CryptoHubMiner") self.window.connect('delete-event', self.on_destroy) try: self.window.set_icon_from_file( self.get_resource_path("imgs/icon.png")) except: pass try: with open(dita_dir + os.path.sep + 'conf.json') as json_data: self.conf = json.load(json_data) except: pass self.box = Gtk.VBox() self.window.add(self.box) self.create_menus() self.hbox_status = Gtk.HBox() self.box.pack_start(self.hbox_status, False, True, 10) self.img = Gtk.Image() self.img.set_from_file(rel_path("imgs", "stop.png")) self.hbox_status.pack_start(self.img, False, True, 10) self.label_status = Gtk.Label('idle') self.label_status.set_markup( '<span size="xx-large" foreground="red">Idle</span>') self.hbox_status.pack_start(self.label_status, False, True, 10) self.fr = Gtk.Frame() try: self.fr.set_shadow_type(Gtk.SHADOW_NONE) except: self.fr.set_shadow_type(Gtk.ShadowType.NONE) self.hbox_status.pack_start(self.fr, True, True, 10) self.box_c1 = Gtk.VBox() self.hbox_status.pack_start(self.box_c1, False, True, 10) self.label_title_cpu = Gtk.Label('') self.box_c1.pack_start(self.label_title_cpu, True, True, 0) self.label_hashrate_cpu = Gtk.Label('') self.box_c1.pack_start(self.label_hashrate_cpu, True, True, 0) self.label_accepted_cpu = Gtk.Label('') self.box_c1.pack_start(self.label_accepted_cpu, True, True, 0) self.label_rejected_cpu = Gtk.Label('') self.box_c1.pack_start(self.label_rejected_cpu, True, True, 0) #self.label_coin_cpu_bal_conf = Gtk.Label('Confirmed balance:') #self.box_c1.pack_start(self.label_coin_cpu_bal_conf, True, True, 0) self.fr2 = Gtk.Frame() try: self.fr2.set_shadow_type(Gtk.SHADOW_NONE) except: self.fr2.set_shadow_type(Gtk.ShadowType.NONE) self.hbox_status.pack_start(self.fr2, True, True, 10) self.box_c2 = Gtk.VBox() self.hbox_status.pack_start(self.box_c2, False, True, 30) self.label_title_gpu = Gtk.Label('') self.box_c2.pack_start(self.label_title_gpu, True, True, 0) self.label_hashrate_gpu = Gtk.Label('') self.box_c2.pack_start(self.label_hashrate_gpu, True, True, 0) self.label_accepted_gpu = Gtk.Label('') self.box_c2.pack_start(self.label_accepted_gpu, True, True, 0) self.label_rejected_gpu = Gtk.Label('') self.box_c2.pack_start(self.label_rejected_gpu, True, True, 0) self.fr3 = Gtk.Frame() try: self.fr3.set_shadow_type(Gtk.SHADOW_NONE) except: self.fr3.set_shadow_type(Gtk.ShadowType.NONE) self.hbox_status.pack_start(self.fr3, True, True, 10) self.box_c3 = Gtk.VBox() self.hbox_status.pack_start(self.box_c3, False, True, 30) self.label_title_gpu3 = Gtk.Label('') self.box_c3.pack_start(self.label_title_gpu3, True, True, 0) self.label_hashrate_gpu3 = Gtk.Label('') self.box_c3.pack_start(self.label_hashrate_gpu3, True, True, 0) self.label_accepted_gpu3 = Gtk.Label('') self.box_c3.pack_start(self.label_accepted_gpu3, True, True, 0) self.label_rejected_gpu3 = Gtk.Label('') self.box_c3.pack_start(self.label_rejected_gpu3, True, True, 0) #gobject.threads_init() pl = platform.platform() dev_info_all = "" if pl.startswith("Windows"): try: dev_info_all = subprocess.check_output(app_dir + os.path.sep + "devcon" + os.path.sep + "devcon.exe" + " find pci\*") except Exception as e: print(e) dev_info_all = "" print("dev_info_all") print(dev_info_all) import cpuinfo info = cpuinfo.get_cpu_info() cpu_threads = info['count'] info2 = cpuinfo.get_cpu_info_from_cpuid() try: cpu_features = info2['flags'] except: cpu_features = info['flags'] else: self.is_linux = True from hwinfo.pci import PCIDevice from hwinfo.pci.lspci import LspciNNMMParser proc_output = subprocess.check_output(["lscpu"]) cpu_features = str(proc_output.split( "Flags:".encode())[1]).split(" ") cpu_threads = str(proc_output.split( "CPU(s):".encode())[1]).split("\\n")[0].replace("b'", "").strip() # Obtain the output of lspci -nnmm from somewhere lspci_output = subprocess.check_output(["lspci", "-nnmm"]) # Parse the output using the LspciNNMMParser object parser = LspciNNMMParser(lspci_output) device_recs = parser.parse_items() # Instantiate the records as PCI devices pci_devs = [PCIDevice(device_rec) for device_rec in device_recs] for dev in pci_devs: if dev.is_subdevice(): dev_info = dev.get_info() dev_info_all += str(dev_info) if "NVIDIA" in dev_info_all: self.nvidia = True #self.found_devices.append(dev_info) if "Radeon" in dev_info_all or "RADEON" in dev_info_all: self.radeon = True #self.found_devices.append(dev_info) print(self.found_devices) try: self.cpu_threads = int(cpu_threads) except: self.cpu_threads = 2 print("features", cpu_features, cpu_threads) if not "avx2" in cpu_features and not "aes" in cpu_features and not "avx" in cpu_features: self.old_cpu = True self.label_cpu = Gtk.Label("Enter your CryptoHub user:"******"inp") except: pass self.user_input = Gtk.TextView() self.user_input_box.pack_start(self.user_input_frame, True, True, 2) self.user_input_frame.add(self.user_input) try: with open(dita_dir + os.path.sep + "user.conf", "r") as myfile: user = myfile.readline().strip() self.user_input.get_buffer().set_text(user) except Exception as e: print(e) self.gtk_style() if self.old_cpu: self.label_cpu = Gtk.Label( "Your CPU is too old and doesn't support AES nor AVX.") self.box.pack_start(self.label_cpu, True, True, 2) else: self.label_cpu = Gtk.Label("Select a coin to mine on CPU:") self.box.pack_start(self.label_cpu, True, True, 2) self.box_nvcpu = Gtk.HBox() self.box.pack_start(self.box_nvcpu, True, True, 2) self.cpuhbox = Gtk.HBox() self.box_nvcpu.pack_start(self.cpuhbox, True, True, 2) try: self.combobox_cpu = Gtk.ComboBoxText() except: self.combobox_cpu = Gtk.combo_box_new_text() for k, el in pools_cpu.items(): self.combobox_cpu.append_text(k) self.cpuhbox.pack_start(self.combobox_cpu, True, True, 2) self.label_cpu_threads = Gtk.Label("Threads:") self.cpuhbox.pack_start(self.label_cpu_threads, False, True, 2) try: self.combobox_threads = Gtk.ComboBoxText() except: self.combobox_threads = Gtk.combo_box_new_text() for i in range(self.cpu_threads): self.combobox_threads.append_text(str(i + 1)) try: self.combobox_threads.set_active(0) except: pass self.cpuhbox.pack_start(self.combobox_threads, True, True, 2) self.hbox = Gtk.HBox() self.box.pack_start(self.hbox, True, True, 3) self.cpu_button = Gtk.Button(label='Start') self.cpu_button.connect('clicked', self.on_cpu_button_clicked) self.hbox.pack_start(self.cpu_button, True, True, 3) self.cpu_button2 = Gtk.Button(label='Stop') self.cpu_button2.set_sensitive(False) self.cpu_button2.connect('clicked', self.on_cpu_button_clicked2) self.hbox.pack_start(self.cpu_button2, True, True, 3) if self.nvidia: self.label_hashrate = Gtk.Label( 'Select a coin to mine on Nvidia GPU(s):') self.box.pack_start(self.label_hashrate, True, True, 3) self.box_nv = Gtk.HBox() self.box.pack_start(self.box_nv, True, True, 3) try: self.combobox_gpu = Gtk.ComboBoxText() self.combobox_gpu_i = Gtk.ComboBoxText() except: self.combobox_gpu = Gtk.combo_box_new_text() self.combobox_gpu_i = Gtk.combo_box_new_text() for k, el in pools_gpu.items(): self.combobox_gpu.append_text(k) self.box_nv.pack_start(self.combobox_gpu, True, True, 3) self.combobox_gpu_i.append_text("Intensity: auto") self.combobox_gpu_i.append_text("Intensity: 13 (lowest)") self.combobox_gpu_i.append_text("Intensity: 15 (low)") self.combobox_gpu_i.append_text("Intensity: 17 (avg)") self.combobox_gpu_i.append_text("Intensity: 19 (high)") self.combobox_gpu_i.append_text("Intensity: 21 (highest)") self.combobox_gpu_i.set_active(0) self.box_nv.pack_start(self.combobox_gpu_i, True, True, 3) self.hbox = Gtk.HBox() self.box.pack_start(self.hbox, True, True, 3) self.gpu_button = Gtk.Button(label='Start') self.gpu_button.connect('clicked', self.on_gpu_button_clicked) self.hbox.pack_start(self.gpu_button, True, True, 3) self.gpu_buttonoff = Gtk.Button(label='Stop') self.gpu_buttonoff.set_sensitive(False) self.gpu_buttonoff.connect('clicked', self.on_gpu_button_off_clicked) self.hbox.pack_start(self.gpu_buttonoff, True, True, 3) if self.radeon: self.label_hashrate2 = Gtk.Label( 'Select a coin to mine on Radeon GPU(s):') self.box.pack_start(self.label_hashrate2, True, True, 3) self.box_nv2 = Gtk.HBox() self.box.pack_start(self.box_nv2, True, True, 3) try: self.combobox_gpu2 = Gtk.ComboBoxText() except: self.combobox_gpu2 = Gtk.combo_box_new_text() for k, el in pools_gpu2.items(): self.combobox_gpu2.append_text(k) self.box_nv2.pack_start(self.combobox_gpu2, True, True, 3) try: self.combobox_gpu2_platform = Gtk.ComboBoxText() except: self.combobox_gpu2_platform = Gtk.combo_box_new_text() self.combobox_gpu2_platform.append_text("Platform 0") self.combobox_gpu2_platform.append_text("Platform 1") self.combobox_gpu2_platform.append_text("Platform 2") try: self.combobox_gpu2_platform.set_active( self.conf['platform_radeon']) except: self.combobox_gpu2_platform.set_active(0) self.box_nv2.pack_start(self.combobox_gpu2_platform, True, True, 10) self.label_sel_platform = Gtk.Label( 'If mining doesnt work try to choose another platform') if self.nvidia: self.label_sel_platform.set_markup( '<span size="small" foreground="maroon">If mining doesn\'t work or loads nvidia gpu instead, try other platforms</span>' ) else: self.label_sel_platform.set_markup( '<span size="small" foreground="maroon">If mining doesn\'t work try other platforms</span>' ) self.box_nv2.pack_start(self.label_sel_platform, True, True, 10) self.hbox2 = Gtk.HBox() self.box.pack_start(self.hbox2, True, True, 10) self.gpu_button2 = Gtk.Button(label='Start') self.gpu_button2.connect('clicked', self.on_gpu_button_clicked2) self.hbox2.pack_start(self.gpu_button2, True, True, 10) self.gpu_button2off = Gtk.Button(label='Stop') self.gpu_button2off.set_sensitive(False) self.gpu_button2off.connect('clicked', self.on_gpu_button_off2_clicked) self.hbox2.pack_start(self.gpu_button2off, True, True, 10) GObject.timeout_add(1000, self.upd) self.window.show_all() if not self.conf["intensity_managment_on"] and self.nvidia: self.combobox_gpu_i.hide() if self.conf["intensity_nvidia"] and self.nvidia: try: self.combobox_gpu_i.set_active( int(self.conf["intensity_nvidia"])) except: pass Gdk.threads_enter() Gtk.main() Gdk.threads_leave()