Python uuid.getnode() Examples

The following are 30 code examples of uuid.getnode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module uuid , or try the search function .
Example #1
Source Project: guiabolso2csv   Author: hsadok   File: guia_bolso.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, email, password):
        self.token=""
        self.email = email
        self.password = password
        hardware_address = str(uuid.getnode()).encode('utf-8')
        self.device_token = hashlib.md5(hardware_address).hexdigest()
        self.session = requests.Session()
        self.token = self.login()
        basic_info = self.get_basic_info()
        self.categories = basic_info["categoryTypes"]
        # self.months = basic_info["GB.months"]
        self.statements = basic_info["accounts"]
        self.fieldnames = [u'id', u'label', u'description', u'date', u'account', u'category',
                           u'subcategory', u'duplicated', u'currency',
                           u'value', u'deleted']
        self.category_resolver = {}
        for categ in self.categories:
            for sub_categ in categ['categories']:
                self.category_resolver[sub_categ['id']] = \
                    (categ['name'], sub_categ['name'])

        self.account_resolver = {}
        for account in self.statements:
            for sub_account in account['statements']:
                self.account_resolver[sub_account['id']] = sub_account['name'] 
Example #2
Source Project: pykit   Author: bsc-s2   File: test_zkutil.py    License: MIT License 6 votes vote down vote up
def test_lock_id_default(self):

        expected = '%012x' % uuid.getnode()

        k = zkutil.lock_id()
        dd(config)
        dd(k)
        self.assertEqual(expected, k.split('-')[0])

        k = zkutil.lock_id(node_id=None)
        dd(k)
        self.assertEqual(expected, k.split('-')[0])

        config.zk_node_id = 'a'
        k = zkutil.lock_id(node_id=None)
        dd(k)
        self.assertEqual('a', k.split('-')[0]) 
Example #3
Source Project: marsnake   Author: turingsec   File: __init__.py    License: GNU General Public License v3.0 6 votes vote down vote up
def get_info(self):
		macaddr = uuid.getnode()
		macaddr = ':'.join(("%012X" % macaddr)[i : i + 2] for i in range(0, 12, 2))
		
		fingerprint = Kdatabase().get_obj("fingerprint")

		return {
			"user_id" : Kdatabase().get_obj("setting")["username"],
			"fullname" : Kdatabase().get_obj("setting")["username"],
			"distro" : common.get_distribution(),
			"os_name" : platform.system(),
			"macaddr" : macaddr,
			"user" : getpass.getuser(),
			"localip" : common.get_ip_gateway(),
			"hostname" : platform.node(),
			"platform" : platform.platform(),
			"version" : constant.VERSION,
			"open_ports" : len(fingerprint["port"]["current"]),
			"accounts" : len(fingerprint["account"]["current"]),
			"uuid" : Kdatabase().get_obj("basic")["uuid"],
			"startup_counts": Kdatabase().get_obj("basic")["startup_counts"]
		} 
Example #4
Source Project: vxTrader   Author: vex1023   File: gfTrader.py    License: MIT License 6 votes vote down vote up
def __init__(self, account, password):

        # 初始化父类
        super(gfLoginSession, self).__init__(account=account, password=password)

        # TODO 从系统中读取磁盘编号
        self.disknum = "S2ZWJ9AF517295"
        self.mac_address = ("".join(c + "-" if i % 2 else c for i, c in \
                                    enumerate(hex(uuid.getnode())[2:].zfill(12)))[:-1]).upper()
        # 校验码的正则表达式
        self.code_rule = re.compile("^[A-Za-z0-9]{5}$")

        # 交易用的sessionId
        self._dse_sessionId = None

        # 融资融券标志
        self.margin_flags = False 
Example #5
Source Project: vxTrader   Author: vex1023   File: yjbTrader.py    License: MIT License 6 votes vote down vote up
def __init__(self, account, password):

        # 初始化父类
        super(yjbLoginSession, self).__init__(account=account, password=password)

        # 初始化登录参数
        self.mac_address = ("".join(c + "-" if i % 2 else c for i, c in \
                                    enumerate(hex(uuid.getnode())[2:].zfill(12)))[:-1]).upper()

        # TODO disk_serial_id and cpuid machinecode 修改为实时获取
        self.disk_serial_id = "ST3250890AS"
        self.cpuid = "-41315-FA76111D"
        self.machinecode = "-41315-FA76111D"

        # 校验码规则
        self.code_rule = re.compile("^[0-9]{4}$")

        if datetime.now() > datetime(year=2016, month=11, day=30, hour=0):
            # raise TraderAPIError('佣金宝交易接口已于2016年11月30日关闭')
            logger.warning('佣金宝交易接口已于2016年11月30日关闭')
        else:
            logger.warning('佣金宝交易接口将于2016年11月30日关闭') 
Example #6
Source Project: rpiapi   Author: victorqribeiro   File: network.py    License: MIT License 6 votes vote down vote up
def network(environ, response, parameter=None):
	status = "200 OK"
	
	header = [
		("Content-Type", "application/json"),
		("Cache-Control", "no-store, no-cache, must-revalidate"),
		("Expires", "0")
	]

	result = {
		"hostname": socket.gethostname(),
        "ip": socket.gethostbyname(socket.gethostname()),
        "ipv4": requests.get('https://api.ipify.org').text,
        "ipv6": requests.get('https://api6.ipify.org').text,
        "mac_address": get_mac()
	}

	response(status, header)
	return [json.dumps(result).encode()] 
Example #7
Source Project: FlowState   Author: skyfpv   File: FSNClient.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, address, port):
        self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server.settimeout(10)
        self.serverIP = address#socket.gethostname()
        self.serverConnected = False
        print(self.serverIP)
        self.serverPort = port#5069
        myIP = socket.gethostname()
        self.networkReady = False
        self.delim = b'\x1E'
        self.buffer = b''
        self.state = FSNObjects.PlayerState(None, None, None, None, None, None, None)
        self.messageHandler = None
        self.serverReady = True
        self.readyToQuit = False
        self.clientID = str(time.perf_counter())+str(get_mac()) 
Example #8
Source Project: gkeepapi   Author: kiwiz   File: __init__.py    License: MIT License 6 votes vote down vote up
def login(self, username, password, state=None, sync=True):
        """Authenticate to Google with the provided credentials & sync.

        Args:
            email (str): The account to use.
            password (str): The account password.
            state (dict): Serialized state to load.

        Raises:
            LoginException: If there was a problem logging in.
        """
        auth = APIAuth(self.OAUTH_SCOPES)

        ret = auth.login(username, password, get_mac())
        if ret:
            self.load(auth, state, sync)

        return ret 
Example #9
Source Project: gkeepapi   Author: kiwiz   File: __init__.py    License: MIT License 6 votes vote down vote up
def resume(self, email, master_token, state=None, sync=True):
        """Authenticate to Google with the provided master token & sync.

        Args:
            email (str): The account to use.
            master_token (str): The master token.
            state (dict): Serialized state to load.

        Raises:
            LoginException: If there was a problem logging in.
        """
        auth = APIAuth(self.OAUTH_SCOPES)

        ret = auth.load(email, master_token, android_id=get_mac())
        if ret:
            self.load(auth, state, sync)

        return ret 
Example #10
Source Project: eavatar-me   Author: eavatar   File: time_uuid.py    License: Apache License 2.0 6 votes vote down vote up
def oid(timestamp_factory=IncreasingMicrosecondClock()):
    """Generate unique identifiers for objects in string format.

    The lexicographical order of these strings are roughly same as their
    generation times.

    Internally, an object ID is composed of a timestamp and the node ID
    so that IDs generated from different nodes can also be compared and
    be ensured to be unique.

    :param timestamp_factory: the timestamp generator
    :return: A string can be used as an UUID.
    """
    timestamp = timestamp_factory()
    ns = timestamp * 1e9
    ts = int(ns // 100) + 0x01b21dd213814000L

    node = uuid.getnode()
    num = (ts << 48L) | node
    return _base58_encode(num) 
Example #11
Source Project: Andromeda   Author: liucaide   File: cd_tools.py    License: MIT License 5 votes vote down vote up
def cd_mac_uuid():
    """
    :return: 网卡作为设备号
    """
    return uuid.UUID(int=uuid.getnode()).hex[-12:] 
Example #12
Source Project: sanic   Author: huge-success   File: logdna_example.py    License: MIT License 5 votes vote down vote up
def get_mac_address():
    h = iter(hex(get_mac())[2:].zfill(12))
    return ":".join(i + next(h) for i in h) 
Example #13
Source Project: rift-python   Author: brunorijsman   File: node.py    License: Apache License 2.0 5 votes vote down vote up
def generate_system_id(self):
        mac_address = uuid.getnode()
        pid = os.getpid()
        system_id = (((mac_address & 0xffffffffff) << 24) |
                     (pid & 0xffff) << 8 |
                     (self._node_nr & 0xff)
                     )

        return system_id 
Example #14
Source Project: pythonpentest   Author: funkandwagnalls   File: hostdetails.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_localhost_details(interfaces_eth, interfaces_wlan):
    hostdata = "None"
    hostname = "None"
    windows_ip = "None"
    eth_ip = "None"
    wlan_ip = "None"
    host_fqdn = "None"
    eth_mac = "None"
    wlan_mac = "None"
    windows_mac = "None"
    hostname = socket.gethostbyname(socket.gethostname())
    if hostname.startswith("127.") and os.name != "nt":
        hostdata = socket.gethostbyaddr(socket.gethostname())
        hostname = str(hostdata[1]).strip('[]')
        host_fqdn = socket.getfqdn()
        for interface in interfaces_eth:
            try:
                eth_ip = get_ip(interface)
                if not "None" in eth_ip:
                    eth_mac = get_mac_address(interface)
                break
            except IOError:
                pass
        for interface in interfaces_wlan:
            try:
                wlan_ip = get_ip(interface)
                if not "None" in wlan_ip:
                    wlan_mac = get_mac_address(interface)
                break
            except IOError:
                pass
    else:
        windows_ip = socket.gethostbyname(socket.gethostname())
        windows_mac = uuid.getnode()
        windows_mac = ':'.join(("%012X" % windows_mac)[i:i+2] for i in range(0, 12, 2))
        hostdata = socket.gethostbyaddr(socket.gethostname())
        hostname = str(socket.gethostname())
        host_fqdn = socket.getfqdn()
    return hostdata, hostname, windows_ip, eth_ip, wlan_ip, host_fqdn, eth_mac, wlan_mac, windows_mac 
Example #15
Source Project: platform   Author: syncloud   File: id.py    License: GNU General Public License v3.0 5 votes vote down vote up
def getmac():
    mac = uuid.getnode()
    mac_formated = ':'.join(("%012x" % mac)[i:i+2] for i in range(0, 12, 2))
    return mac_formated 
Example #16
Source Project: mars   Author: mars-project   File: events.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, category=None, level=None, event_type=None, owner=None,
                 time_start=None, time_end=None, event_id=None):
        self.category = category
        self.level = level or EventLevel.NORMAL
        self.event_type = event_type
        self.owner = owner
        self.time_start = time_start
        self.time_end = time_end

        self.event_id = event_id or tokenize(
            uuid.getnode(), time.time(), category, level, event_type, owner) 
Example #17
Source Project: pygraphistry   Author: graphistry   File: util.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def fingerprint():
    md5 = hashlib.md5()
    # Hostname, OS, CPU, MAC,
    data = [p.node(), p.system(), p.machine(), str(uuid.getnode())]
    md5.update(''.join(data).encode('utf8'))
    return "%s-pygraphistry-%s" % (md5.hexdigest()[:8], sys.modules['graphistry'].__version__) 
Example #18
Source Project: PySide_For_Amazon_Order   Author: cundi   File: captcha_handler.py    License: MIT License 5 votes vote down vote up
def login(self):
        flag = True
        if self.loginUrl is not None:
            try:
                mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
                self.params.append(
                    ('KEY', self.md5(self.softKey.upper() + self.user.upper()) + mac))
                self.opener.addheaders = self.params
                url = "http://" + self.loginUrl
                url += "/Upload/Login.aspx?U=%s&p=%s" % (
                    self.user, self.md5(self.pwd))
                try:
                    response = self.opener.open(url, None, 60)
                    if response.code == 200:
                        body = response.read()
                        if body is not None:
                            if body.find("-") > 0:
                                us = body.split("_")
                                self.uid = us[0]
                                self.uKey = body.strip()
                                print '登录成功,用户ID是:', self.uid
                                flag = True
                            else:
                                print '登录失败,错误代码是:', body
                                flag = False
                except Exception, e:
                    print "Error:Login Request"
                    print e
            except Exception, e:
                print "Error:Login Params "
                print e 
Example #19
Source Project: ironpython2   Author: IronLanguages   File: test_uuid.py    License: Apache License 2.0 5 votes vote down vote up
def test_getnode(self):
        node1 = uuid.getnode()
        self.assertTrue(0 < node1 < (1 << 48), '%012x' % node1)

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.assertEqual(node1, node2, '%012x != %012x' % (node1, node2))

    # bpo-32502: UUID1 requires a 48-bit identifier, but hardware identifiers
    # need not necessarily be 48 bits (e.g., EUI-64). 
Example #20
Source Project: ironpython2   Author: IronLanguages   File: test_uuid.py    License: Apache License 2.0 5 votes vote down vote up
def test_uuid1_eui64(self):
        # Confirm that uuid.getnode ignores hardware addresses larger than 48
        # bits. Mock out each platform's *_getnode helper functions to return
        # something just larger than 48 bits to test. This will cause
        # uuid.getnode to fall back on uuid._random_getnode, which will
        # generate a valid value.
        too_large_getter = lambda: 1 << 48

        uuid_real__node = uuid._node
        uuid_real__NODE_GETTERS_WIN32 = uuid._NODE_GETTERS_WIN32
        uuid_real__NODE_GETTERS_UNIX = uuid._NODE_GETTERS_UNIX
        uuid._node = None
        uuid._NODE_GETTERS_WIN32 = [too_large_getter]
        uuid._NODE_GETTERS_UNIX = [too_large_getter]
        try:
            node = uuid.getnode()
        finally:
            uuid._node = uuid_real__node
            uuid._NODE_GETTERS_WIN32 = uuid_real__NODE_GETTERS_WIN32
            uuid._NODE_GETTERS_UNIX = uuid_real__NODE_GETTERS_UNIX

        self.assertTrue(0 < node < (1 << 48), '%012x' % node)

        # Confirm that uuid1 can use the generated node, i.e., the that
        # uuid.getnode fell back on uuid._random_getnode() rather than using
        # the value from too_large_getter above.
        try:
            uuid.uuid1(node=node)
        except ValueError as e:
            self.fail('uuid1 was given an invalid node ID') 
Example #21
Source Project: HomeAssistant_Components   Author: charleyzhu   File: utility.py    License: Apache License 2.0 5 votes vote down vote up
def get_mac_address():
    mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
    return ":".join([mac[e:e + 2] for e in range(0, 11, 2)]) 
Example #22
Source Project: HomeAssistant_Components   Author: charleyzhu   File: utility.py    License: Apache License 2.0 5 votes vote down vote up
def get_mac_address_noformat():
    return uuid.UUID(int=uuid.getnode()).hex[-12:] 
Example #23
Source Project: HomeAssistant_Components   Author: charleyzhu   File: utility.py    License: Apache License 2.0 5 votes vote down vote up
def get_bridgeid():
    mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
    return mac[:6] + "fffe" + mac[6:] 
Example #24
Source Project: FuzzFlow   Author: talos-vulndev   File: helper.py    License: MIT License 5 votes vote down vote up
def get_mac(self):
        mac = getnode()
        return "%02x:%02x:%02x:%02x:%02x:%02x" % (
            mac >> 40,
            mac >> 32 & 0xff,
            mac >> 24 & 0xff,
            mac >> 16 & 0xff,
            mac >> 8 & 0xff,
            mac & 0xff,
        ) 
Example #25
Source Project: voicetools   Author: namco1992   File: utils.py    License: Apache License 2.0 5 votes vote down vote up
def get_mac_address():
    mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
    return ":".join([mac[e:e+2] for e in range(0, 11, 2)]) 
Example #26
Source Project: python-snapcast   Author: happyleavesaoc   File: __init__.py    License: MIT License 5 votes vote down vote up
def mac():
    """ Get MAC. """
    from uuid import getnode as get_mac
    return ':'.join(("%012x" % get_mac())[i:i+2] for i in range(0, 12, 2)) 
Example #27
Source Project: BinderFilter   Author: dxwu   File: test_uuid.py    License: MIT License 5 votes vote down vote up
def test_getnode(self):
        import sys
        node1 = uuid.getnode()
        self.check_node(node1, "getnode1")

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.check_node(node2, "getnode2")

        self.assertEqual(node1, node2) 
Example #28
Source Project: rpisurv   Author: SvenVD   File: stats.py    License: GNU General Public License v2.0 5 votes vote down vote up
def generate_uniqid():
    mac=str(get_mac())

    #Hash the mac address to ensure anonymity
    m = hashlib.new('sha256')
    m.update(mac)
    mac_hash=m.hexdigest()
    logger.info("Unique id of this installation is " + mac_hash)
    return str(mac_hash) 
Example #29
Source Project: f-surfing   Author: YianAndCode   File: fsurfing.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def get_mac_address():
    if platform.system() == "Windows":
        import uuid
        mac=uuid.UUID(int = uuid.getnode()).hex[-12:] 
        return "-".join([mac[e:e+2] for e in range(0,11,2)]).upper()
    ic=os.popen("ifconfig |grep -B1 \'"+ IP +"\' |awk \'/HWaddr/ { print $5 }\'").read()
    ic=str(ic).split("\n")[0]
    ic=ic.replace(":","-")
    return ic.upper() 
Example #30
Source Project: oss-ftp   Author: aliyun   File: test_uuid.py    License: MIT License 5 votes vote down vote up
def test_getnode(self):
        node1 = uuid.getnode()
        self.check_node(node1, "getnode1")

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.check_node(node2, "getnode2")

        self.assertEqual(node1, node2)