示例#1
0
    def test_05_search_profile(self):
        profiles = Profiles()
        profiles.setConfiguration("tests/files/test_valid.xml")
        profile = profiles.getProfile('/live/test')

        self.assertFalse(profile == None)
        self.assertEqual(profile['name'], 'test')
示例#2
0
    def test_09_delete_core(self):
        profiles = Profiles()
        profiles.setConfiguration('tests/files/test_valid.xml')

        profiles.delete('/live')

        self.assertEqual(profiles.getProfile('/live')['subprofiles'], {})
示例#3
0
    def test_08_delete_subprofile(self):
        profiles = Profiles()
        profiles.setConfiguration('tests/files/test_valid.xml')

        profiles.delete('/live/pokus/New_Profile')

        self.assertEqual(profiles.getProfile('/live/pokus/New_Profile'), None)
示例#4
0
    def test_04_invalid_xml(self):
        """TEST04 - Loading invalid XML 3/3"""

        profiles = Profiles(())
        with self.assertRaises(AttributeError) as ctx:
            profiles.setConfiguration('tests/files/test_invalid3.xml')

        self.assertTrue('get_text' in str(ctx.exception))
示例#5
0
    def test_03_invalid_xml(self):
        """TEST03 - Loading invalid XML 2/3"""

        profiles = Profiles()
        with self.assertRaises(ProfilesError) as ctx:
            profiles.setConfiguration('tests/files/test_invalid2.xml')

        self.assertTrue('Unexpected tag in sourcelist' in str(ctx.exception))
示例#6
0
    def test_02_invalid_xml(self):
        """TEST02 - Loading invalid XML 1/3"""

        profiles = Profiles()
        with self.assertRaises(KeyError) as ctx:
            profiles.setConfiguration("tests/files/test_invalid.xml")

        self.assertTrue('name' in str(ctx.exception))
示例#7
0
    def compute_profiles(self):
        """Computes beta/theta/c reactivity values after pair data have been processed.

           :return: a :class:`.profiles.Profiles` object, which contains the reactivities for all targets.
        """

        self._profiles = Profiles(self._targets, self.run, self._processor.counters)
        self._profiles.compute()
        return self._profiles
示例#8
0
    def test_06_import_export_import(self):
        profiles = Profiles()
        profiles.setConfiguration('tests/files/test_valid.xml')
        profiles.exportXML('/tmp/exportTest.xml')
        old_json = json.loads(profiles.getJSONString())

        profiles.setConfiguration("/tmp/exportTest.xml")
        new_json = json.loads(profiles.getJSONString())

        self.assertEqual(json.dumps(old_json, sort_keys=True),
                         json.dumps(new_json, sort_keys=True))

        os.remove('/tmp/exportTest.xml')
示例#9
0
    def test_07_create_subprofile(self):
        profiles = Profiles()
        profiles.setConfiguration("tests/files/test_valid.xml")

        dummy = {
            "name": "test_changed",
            "path": "/live/test",
            "type": "normal",
            "channels": [{
                "name": "source1",
                "filter": "*",
                "sources": ["ch1"]
            }],
            "subprofiles": []
        }

        profiles.createSubprofile("/live", dummy)
        prf_json = json.loads(profiles.getJSONString())

        self.assertEqual(
            prf_json["live"]['subprofiles']["test_changed"]['name'],
            'test_changed')
示例#10
0
 def test_generate_password(self):
     test_profiles = Profiles("thuitafaith", "*****@*****.**", "prrr")
     test_profiles.save_profiles()
     password_changed = test_profiles.generate_password("thuitafaith", 8)
     self.assertTrue(len(test_profiles.password), 8)
示例#11
0
 def setUp(self):
     self.new_profiles = Profiles("thuitafaith", "*****@*****.**",
                                  "prrr")
示例#12
0
 def test_find_profiles_by_username(self):
     self.new_profiles.save_profiles()
     test_profiles = Profiles("tinakathambi", "*****@*****.**", "skrrr")
     test_profiles.save_profiles()
     found_profiles = Profiles.find_by_username("tinakathambi")
     self.assertEqual(found_profiles.username, test_profiles.username)
示例#13
0
 def test_profiles_exists(self):
     self.new_profiles.save_profiles()
     test_profiles = Profiles("thuitafaith", "*****@*****.**", "prrr")
     test_profiles.save_profiles()
     profiles_exists = Profiles.profiles_exist("thuitafaith")
     self.assertTrue(profiles_exists)
示例#14
0
 def test_delete_profiles(self):
     self.new_profiles.save_profiles()
     test_profiles = Profiles("tinakathambi", "*****@*****.**", "skrrr")
     test_profiles.save_profiles()
     self.new_profiles.delete_profiles()
     self.assertEqual(len(Profiles.profiles_list), 1)
示例#15
0
 def getProfiles(self):
   return Profiles(self.key, self.secret, self.ext)
示例#16
0
 def test_01_valid_xml(self):
     """Try to parse valid Profiles file"""
     profiles = Profiles('tests/files/test_valid.xml')
     self.assertTrue(profiles.getJSONString() != '[{}]')
示例#17
0
from pymongo import MongoClient
from random import randint
from profiles import Profiles
from keyboard import general_keyboard, work_keyboard
from work import Work

cluster = MongoClient(
    f"mongodb+srv://{config.login_mongo}:{config.pass_mongo}@abucontroller.vzuyo.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
)
db = cluster.chats
vk_session = vk_api.VkApi(token=config.TOKEN)
longpoll = VkBotLongPoll(vk_session, config.group_id)
characteristics = [
    "Имя", "Баланс", "В банке", "Статус", "Судимости", "Состояние"
]
all_profiles = Profiles()
all_jobs = Work()

for event in longpoll.listen():
    '''
    if event.type == VkBotEventType.group_join:
        id_chat = event.chat_id
        if str(id_chat) not in db.getCollectionNames():
            db.createCollevtion(str(id_chat))
    '''
    if event.type == VkBotEventType.MESSAGE_NEW:
        if event.from_chat:
            id_peer = event.object.message["peer_id"]
            id_chat = event.chat_id
            msg = event
            print(msg)
示例#18
0
 def test_copy_password(self):
     test_profiles = Profiles("thuitafaith", "*****@*****.**", "prrr")
     test_profiles.save_profiles()
     test_profiles.generate_password("thuitafaith", 9)
     Profiles.copy_password("thuitafaith")
     self.assertEqual(test_profiles.password, pyperclip.paste())
示例#19
0
文件: device.py 项目: rcespa/minotaur
    def get_profile_for_algo(self, algorithm=None):
        if algorithm == None:
            algorithm = self.algos[0]['algo']

        return Profiles().get_for_device_algo(self, algorithm)
示例#20
0
def create_profile(fname, lname, password):
    new_account = Profiles(fname, lname, password)
    return new_account
示例#21
0
import xml.dom

# order of imports is important (partly circular)
from . import util
import errorhandler
log = errorhandler.ErrorHandler()

import css
import stylesheets
from parse import CSSParser

from serialize import CSSSerializer
ser = CSSSerializer()

from profiles import Profiles
profile = Profiles(log=log)

# used by Selector defining namespace prefix '*'
_ANYNS = -1


class DOMImplementationCSS(object):
    """This interface allows the DOM user to create a CSSStyleSheet
    outside the context of a document. There is no way to associate
    the new CSSStyleSheet with a document in DOM Level 2.

    This class is its *own factory*, as it is given to
    xml.dom.registerDOMImplementation which simply calls it and receives
    an instance of this class then.
    """
    _features = [('css', '1.0'), ('css', '2.0'), ('stylesheets', '1.0'),
示例#22
0
    def start(self,
              device,
              pool_name,
              miner,
              algorithm,
              region,
              quick=False,
              force=False):
        self.miner = miner
        self.device = device
        self.default_profile = Config().get('device_profiles.default')

        Miners().reload_config()

        device.pin = {
            'pool_name': pool_name,
            'miner_name': miner.name,
            'algorithm': algorithm,
            'region': region
        }

        if not Config().get('calibration'):
            Log().add('fatal', "calibration config missing from config file")

        for key in [
                "hashrate_stabilisation_timeout_mins",
                "hashrate_stabilisation_tolerance",
                "hashrate_stabilisation_consecutive_readings_required",
                "algorithm_start_timeout"
        ]:
            if Config().get('calibration.%s' % (key)) == None:
                Log().add('fatal',
                          "missing config option: calibration.%s" % (key))

        if Config().get('calibration.power_tuning.enable'):
            for key in ["decrement_watts", "acceptable_loss_percent"]:
                if not Config().get('calibration.power_tuning.%s' % (key)):
                    Log().add(
                        'fatal',
                        "missing config option: calibration.power_tuning.%s" %
                        (key))

        Config().set('pools.%s.append_device_id_to_worker_name' % (pool_name),
                     False)

        if pool_name == 'miningpoolhub':
            if Config().get('pools.miningpoolhub.hub_workers.%s' %
                            (algorithm))[-5:] != 'CALIB':
                Config().set(
                    'pools.miningpoolhub.hub_workers.%s' % (algorithm),
                    Config().get('pools.miningpoolhub.hub_workers.%s' %
                                 (algorithm)) + 'CALIB')
        else:
            if Config().get('pools.%s.worker_name' %
                            (pool_name))[-5:] != 'CALIB':
                Config().set(
                    'pools.%s.worker_name' % (pool_name),
                    Config().get('pools.%s.worker_name' % (pool_name)) +
                    "CALIB")

        if quick:
            Config().set('calibration.power_tuning.enable', False)

        profile = Profiles().get_for_device_algo(device, algorithm)

        Log().add('info', '     device id: %d' % (device.id))
        Log().add('info', '          pool: %s' % (pool_name))
        Log().add('info', '  device class: %s' % (device.dclass))
        Log().add('info', 'device profile: %s' % (profile.name))
        Log().add('info', '         miner: %s' % (miner.name))
        Log().add('info', '     algorithm: %s' % (algorithm))
        Log().add('info', '        region: %s' % (region))

        Miners().poll()
        Miners().get_device_state(device)

        if device.state != 'inactive':
            if device.state == 'calibrating':
                device.log(
                    'fatal',
                    'this device is already being used for calibration')

            if force:
                device.log('info', 'terminating existing worker')
                if not device.stop(True):
                    device.log('fatal', 'failed to stop existing worker')
            else:
                device.log(
                    'fatal',
                    'unable to start calibration - device is in use (use --force to override)'
                )

        self.set_pin(device.id)

        default_power_limit = device.default_power_limit_f
        min_power_limit = device.min_power_limit_f
        max_power_limit = device.max_power_limit_f

        if max_power_limit == 0:
            device.log('info', 'device does not support power monitoring')
        else:
            device.log('info', 'max power limit: %d W' % (max_power_limit))

        device.log(
            'info', 'stabilisation tolerance: %.2f%%' %
            (Config().get('calibration.hashrate_stabilisation_tolerance')))

        if Config().get('debug'):
            device.log('debug', 'loading default profile')

        Nvidia().set_default_profile(device)

        if Config().get('debug'):
            device.log('debug', 'initialising pools')

        Pools()

        sample_timeout = Config().get(
            'calibration.hashrate_stabilisation_timeout_mins')

        if default_power_limit != None and Config().get(
                'calibration.power_tuning.enable'):
            device.log(
                'info',
                'starting initial run at max power limit [timeout=%dmins]' %
                (sample_timeout))
        else:
            device.log(
                'info',
                'starting single run [timeout=%dmins]' % (sample_timeout))

        Miners().poll()
        Miners().get_device_state(device)

        if device.state != 'calibrating':
            if not device.start(True):
                device.log('fatal', 'worker failed to start')

        if Config().get('calibration.power_tuning.enable'):
            if not device.power_supported():
                device.log('info', 'device does not support power monitoring')
            else:
                device.set_power_limit(max_power_limit)

        initial_hashrate, initial_max_power_draw = self.get_max_hashrate_and_power_draw(
            miner, device, sample_timeout * 60)

        if initial_hashrate == None:
            device.log(
                'info',
                'skipping algorithm as we failed to get a stable reading')
            print ""
            return

        if initial_max_power_draw != None and initial_max_power_draw > max_power_limit:
            initial_max_power_draw = max_power_limit

        device.log(
            'info', 'benchmark hashrate: %s' %
            (Units().hashrate_str(initial_hashrate)))

        if initial_max_power_draw != None:
            device.log('info',
                       'max power draw: %.2f' % (initial_max_power_draw))
            initial_power_limit = int(math.ceil(initial_max_power_draw))

        hashrate = initial_hashrate

        if initial_max_power_draw == None:
            power_limit = None
        elif Config().get('calibration.power_tuning.enable'):
            if max_power_limit == 0 or min_power_limit == 0 or default_power_limit == 0:
                device.log(
                    'error',
                    'device did not give us sane values for its min/max/default power limits'
                )
                device.log(
                    'error',
                    'unable to proceed with power calibration - device may not support changing the power limit'
                )

                power_limit = default_power_limit
            else:
                power_limit = initial_power_limit

                device.log('info', 'tuning power limit for optimum efficiency')
                hashrate, power_limit = self.do_power_calibration(
                    device, power_limit, miner, hashrate, min_power_limit)
        else:
            power_limit = default_power_limit

        Nvidia().set_default_profile(device)

        self.unset_pin(device.id)

        device.log('info', 'storing calibration data')

        Calibration().update_calibration_data(device.dclass, miner.name,
                                              algorithm, hashrate, power_limit)

        if not device.stop(True):
            device.log('fatal', "failed to stop the miner process")

        print ""

        device.log(
            'info',
            '   calibrated hashrate: %s' % (Units().hashrate_str(hashrate)))

        if power_limit != None:
            device.log('info',
                       'calibrated power limit: %.2f W' % (power_limit))

        print ""