本文整理汇总了Python中uuid.getnode方法的典型用法代码示例。如果您正苦于以下问题:Python uuid.getnode方法的具体用法?Python uuid.getnode怎么用?Python uuid.getnode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uuid
的用法示例。
在下文中一共展示了uuid.getnode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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']
示例2: test_lock_id_default
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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])
示例3: get_info
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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"]
}
示例4: __init__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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
示例5: __init__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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日关闭')
示例6: network
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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()]
示例7: __init__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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())
示例8: login
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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
示例9: resume
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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
示例10: oid
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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)
示例11: cd_mac_uuid
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
def cd_mac_uuid():
"""
:return: 网卡作为设备号
"""
return uuid.UUID(int=uuid.getnode()).hex[-12:]
示例12: get_mac_address
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
def get_mac_address():
h = iter(hex(get_mac())[2:].zfill(12))
return ":".join(i + next(h) for i in h)
示例13: generate_system_id
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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
示例14: get_localhost_details
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
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
示例15: getmac
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import getnode [as 别名]
def getmac():
mac = uuid.getnode()
mac_formated = ':'.join(("%012x" % mac)[i:i+2] for i in range(0, 12, 2))
return mac_formated