def __init__(self, parent, *args, **kwargs): wx.Frame.__init__(self, parent, *args, **kwargs) self.SetSizeHints(minW=500, minH=500) self._devices = [] self._settings = None self._benchmarks = None notebook = wx.Notebook(self) self._mining_screen = MiningScreen(notebook, devices=self._devices, window=self) notebook.AddPage(self._mining_screen, text='Mining') def settings_callback(new_settings): self.read_settings(new_settings) self._save_persist() self._settings_screen = SettingsScreen( notebook, commit_callback=settings_callback) notebook.AddPage(self._settings_screen, text='Settings') self.Bind(EVT_BALANCE, self.OnNewBalance) self._timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, lambda event: self._update_balance(), self._timer) self._timer.Start(milliseconds=BALANCE_UPDATE_MIN * 60 * 1e3) self._mining = False self._mining_thread = None self.Bind(EVT_MINING_STATUS, self.OnMiningStatus) self._devices = nvidia_devices() self._load_persist()
import unittest from time import sleep import nuxhash.settings from nuxhash.devices.nvidia import enumerate_devices as nvidia_devices from nuxhash.download.downloads import make_miners from nuxhash.miners.excavator import Excavator from tests import get_test_devices devices = nvidia_devices() @unittest.skipIf(len(devices) == 0, 'requires an nvidia graphics card') class TestExcavator(unittest.TestCase): def setUp(self): self.configdir = nuxhash.settings.DEFAULT_CONFIGDIR self.device = devices[0] self.settings = nuxhash.settings.DEFAULT_SETTINGS self.settings['nicehash']['wallet'] = '3Qe7nT9hBSVoXr8rM2TG6pq82AmLVKHy23' self.alt_settings = nuxhash.settings.DEFAULT_SETTINGS self.alt_settings['nicehash']['wallet'] = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' self.alt_settings['nicehash']['workername'] = 'nuxhashtest' self.excavator = Excavator(self.configdir) self.excavator.settings = self.settings self.equihash = next(a for a in self.excavator.algorithms if a.algorithms == ['equihash'])
def main(): sys.excepthook = excepthook argp = argparse.ArgumentParser( description='Sell GPU hash power on the NiceHash market.') argp_benchmark = argp.add_mutually_exclusive_group() argp_benchmark.add_argument('--benchmark-all', action='store_true', help='benchmark all algorithms on all devices') argp_benchmark.add_argument( '--benchmark-missing', action='store_true', help='benchmark algorithm-device combinations not measured') argp.add_argument('--list-devices', action='store_true', help='list all devices') argp.add_argument('-v', '--verbose', action='store_true', help='print more information to the console log') argp.add_argument( '--show-mining', action='store_true', help='print output from mining processes, implies --verbose') argp.add_argument('-c', '--configdir', nargs=1, default=[settings.DEFAULT_CONFIGDIR], help=('directory for configuration and benchmark files' + ' (default: ~/.config/nuxhash/)')) argp.add_argument('--version', action='store_true', help='show nuxhash version') args = argp.parse_args() config_dir = Path(args.configdir[0]) if args.version: print(f'nuxhash daemon {__version__}') return if args.show_mining: log_level = logging.DEBUG elif args.verbose: log_level = logging.INFO else: log_level = logging.WARN logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=log_level) all_devices = nvidia_devices() nx_settings = settings.load_settings(config_dir) nx_benchmarks = settings.load_benchmarks(config_dir, all_devices) # If no wallet configured, do initial setup prompts. if nx_settings['nicehash']['wallet'] == '': wallet, workername, region = initial_setup() nx_settings['nicehash']['wallet'] = wallet nx_settings['nicehash']['workername'] = workername nx_settings['nicehash']['region'] = region # Download and initialize miners. downloadables = make_miners(config_dir) for d in downloadables: if not d.verify(): logging.info(f'Downloading {d.name}') d.download() nx_miners = [miner(config_dir) for miner in all_miners] for miner in nx_miners: miner.settings = nx_settings # Select code path(s), benchmarks and/or mining. if args.benchmark_all: nx_benchmarks = run_missing_benchmarks(nx_miners, nx_settings, all_devices, settings.EMPTY_BENCHMARKS) elif args.benchmark_missing: nx_benchmarks = run_missing_benchmarks(nx_miners, nx_settings, all_devices, nx_benchmarks) elif args.list_devices: list_devices(all_devices) else: nx_benchmarks = run_missing_benchmarks(nx_miners, nx_settings, all_devices, nx_benchmarks) session = MiningSession(nx_miners, nx_settings, nx_benchmarks, all_devices) # Attach the SIGINT signal for quitting. # NOTE: If running in a shell, Ctrl-C will get sent to our subprocesses too, # because we are the foreground process group. Miners will get killed # before we have a chance to properly shut them down. signal.signal(signal.SIGINT, lambda signum, frame: session.stop()) session.run() settings.save_settings(config_dir, nx_settings) settings.save_benchmarks(config_dir, nx_benchmarks) terminate()
def _ProbeDevices(self): return nvidia_devices()
def main(): argp = argparse.ArgumentParser( description='Sell GPU hash power on the NiceHash market.') argp_benchmark = argp.add_mutually_exclusive_group() argp_benchmark.add_argument( '--benchmark-all', action='store_true', help='benchmark all algorithms on all devices') argp_benchmark.add_argument( '--benchmark-missing', action='store_true', help='benchmark algorithm-device combinations not measured') argp.add_argument('--list-devices', action='store_true', help='list all devices') argp.add_argument('-v', '--verbose', action='store_true', help='print more information to the console log') argp.add_argument('--show-mining', action='store_true', help='print output from mining processes, implies --verbose') argp.add_argument( '-c', '--configdir', nargs=1, default=[settings.DEFAULT_CONFIGDIR], help=('directory for configuration and benchmark files' + ' (default: ~/.config/nuxhash/)')) argp.add_argument('--version', action='store_true', help='show nuxhash version') args = argp.parse_args() config_dir = Path(args.configdir[0]) if args.version: print('nuxhash daemon %s' % __version__) return if args.show_mining: log_level = logging.DEBUG elif args.verbose: log_level = logging.INFO else: log_level = logging.WARN logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=log_level) all_devices = nvidia_devices() nx_settings = settings.load_settings(config_dir) nx_benchmarks = settings.load_benchmarks(config_dir, all_devices) # If no wallet configured, do initial setup prompts. if nx_settings['nicehash']['wallet'] == '': wallet, workername, region = initial_setup() nx_settings['nicehash']['wallet'] = wallet nx_settings['nicehash']['workername'] = workername nx_settings['nicehash']['region'] = region # Download and initialize miners. downloadables = make_miners(config_dir) for d in downloadables: if not d.verify(): logging.info('Downloading %s' % d.name) d.download() nx_miners = [miner(config_dir) for miner in all_miners] for miner in nx_miners: miner.settings = nx_settings # Select code path(s), benchmarks and/or mining. if args.benchmark_all: nx_benchmarks = run_missing_benchmarks( nx_miners, nx_settings, all_devices, settings.EMPTY_BENCHMARKS) elif args.benchmark_missing: nx_benchmarks = run_missing_benchmarks( nx_miners, nx_settings, all_devices, nx_benchmarks) elif args.list_devices: list_devices(all_devices) else: nx_benchmarks = run_missing_benchmarks( nx_miners, nx_settings, all_devices, nx_benchmarks) session = MiningSession(nx_miners, nx_settings, nx_benchmarks, all_devices) session.run() settings.save_settings(config_dir, nx_settings) settings.save_benchmarks(config_dir, nx_benchmarks)