本文整理汇总了Python中uuid.get_mac函数的典型用法代码示例。如果您正苦于以下问题:Python get_mac函数的具体用法?Python get_mac怎么用?Python get_mac使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_mac函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
xbmc.log("Reading Settings.xml")
if int(xbmc.getInfoLabel('System.BuildVersion')[:2]) < 18:
XBMC_DIALOG_BUSY_OPEN = "ActivateWindow(busydialog)"
XBMC_DIALOG_BUSY_CLOSE = "Dialog.Close(busydialog)"
from uuid import getnode as get_mac
if hasattr(os, 'uname'):
system = os.uname()[4]
else:
import platform
system = platform.uname()[5]
if system == 'armv6l':
try:
mac = open('/sys/class/net/eth0/address').readline()
self.XNEWA_MAC = hex(int('0x'+ mac.replace(':',''),16))
except:
self.XNEWA_MAC = str(hex(get_mac()))
else:
self.XNEWA_MAC = str(hex(get_mac()))
self.loadFromSettingsXML()
return
开发者ID:emveepee,项目名称:X-NEWA,代码行数:26,代码来源:XNEWA_Settings.py
示例2: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'-int', '--interface', type=str, help='interface to change')
parser.add_argument(
'-ls', '--list', help='list available interfaces',
action='store_true')
args = parser.parse_args()
if len(sys.argv) == 1:
parser.print_help()
exit()
if args.list:
interfaces = localifs()
mac = {}
for i in range(0, len(interfaces)):
print interfaces[i][0], ":", get_mac(interfaces[i][0]), ":", \
interfaces[i][1]
exit()
mac = get_mac(args.interface)
print "[+] Old MAC Address is: ", mac
status = change_mac(args.interface, mac)
print "status: ", status
开发者ID:sjm4584,项目名称:spoof-mac-address-,代码行数:25,代码来源:mac_changer.py
示例3: __init__
def __init__(self):
# ----------------- NIC INFO -----------------
self.os = platform.dist()[0]
# If system is "debian":
if self.os == 'debian':
self.hostname = socket.gethostname()
self.iface = ni.interfaces()[1]
self.ipaddress = ni.ifaddresses(self.iface)[ni.AF_INET][0]['addr']
self.subnet = ni.ifaddresses(self.iface)[ni.AF_INET][0]['netmask']
self.gateways = ni.gateways()['default'][ni.AF_INET][0]
# --- OS INFO ---------------------
self.os_ver = platform.dist()[1]
self.mac = ''.join('%012x' % get_mac())
self.ip_data = get_ip()
self.path_ip = '/etc/network/interfaces'
self.dns_file = '/etc/resolv.conf'
# If system is "Arch Linux":
else:
self.hostname = socket.gethostname()
self.iface = ni.interfaces()[1]
self.ipaddress = ni.ifaddresses(self.iface)[ni.AF_INET][0]['addr']
self.subnet = ni.ifaddresses(self.iface)[ni.AF_INET][0]['netmask']
self.gateways = ni.gateways()['default'][ni.AF_INET][0]
# --- OS INFO ---------------------
self.os_ver = platform.dist()[1]
self.mac = ''.join('%012x' % get_mac())
self.ip_data = get_ip()
self.path_ip = '/etc/netctl/eth0'
self.dns_file = '/etc/resolv.conf'
logger.debug('GET IP SETTING OK!')
开发者ID:jense-arntz,项目名称:Full-Stack-Server-Client-App,代码行数:31,代码来源:views.py
示例4: mac_addr_info
def mac_addr_info():
"""Returns mac address.
"""
mac = get_mac()
if mac == get_mac(): # not random generated
hexa = '%012x' % mac
value = ':'.join(hexa[i:i+2] for i in range(0, 12, 2))
else:
value = None
return {'mac': value}
开发者ID:johnnoone,项目名称:facts,代码行数:10,代码来源:system_grafts.py
示例5: getScannerID
def getScannerID() :
from uuid import getnode as get_mac
# ScannerID pattern
scannerPattern = r"^[0-9]{1,15}"
if (re.match(scannerPattern, str(get_mac())) == None) :
return -1
print ("Scanner Id : " + str(get_mac()))
return str(get_mac())
开发者ID:Corb3nik,项目名称:Kitscan,代码行数:11,代码来源:runScanner.py
示例6: get_speech
def get_speech(self, phrase):
if self.token == '':
self.token = self.get_token()
query = {'tex': phrase,
'lan': 'zh',
'tok': self.token,
'ctp': 1,
'cuid': str(get_mac())[:32],
'per': self.per
}
r = requests.post('http://tsn.baidu.com/text2audio',
data=query,
headers={'content-type': 'application/json'})
try:
r.raise_for_status()
if r.json()['err_msg'] is not None:
self._logger.critical('Baidu TTS failed with response: %r',
r.json()['err_msg'],
exc_info=True)
return None
except Exception:
pass
with tempfile.NamedTemporaryFile(suffix='.mp3', delete=False) as f:
f.write(r.content)
tmpfile = f.name
return tmpfile
开发者ID:codywon,项目名称:dingdang-robot,代码行数:26,代码来源:tts.py
示例7: mapfn
def mapfn(key, value):
import multiprocessing
from uuid import getnode as get_mac
# Можно собирать дополнительную информацию
count_cores = multiprocessing.cpu_count()
key2 = str(get_mac())
yield key2, count_cores
开发者ID:zaqwes8811,项目名称:tech-sandbox,代码行数:7,代码来源:count_cores_task.py
示例8: user_setup
def user_setup(ip, port=None, user=None, password=None, root=None): # TODO IP PORT
if not user:
print 'TODO'
user=raw_input("Enter your username: ")
else:
try:
nick = get_mac()
data = {"username": user, "root_dir": root, "nick": str(nick),
"is_syncing": True, "password": password, 'last_sync': "0"}
path = os.path.expanduser('~') + '/.onedirclient/client.json'
conf_folder = os.path.expanduser('~') + '/.onedirclient'
if not os.path.exists(conf_folder):
os.mkdir(conf_folder)
with open(path, 'w') as filename:
json.dump(data, filename)
watch_folder = os.path.expanduser('~') + '/OneDirFiles'
if not os.path.exists(watch_folder):
os.mkdir(watch_folder)
# ftpclient = OneDirFtpClient(ip, port, user, nick, password, root)
db = conf_folder + '/sync.db'
ta = TableAdder(db, 'local')
ta.add_column('time')
ta.add_column('cmd')
ta.add_column('line')
ta.commit()
# print 3
except:
print 'invalid credentials'
开发者ID:Devon-Peroutky,项目名称:OneDir,代码行数:28,代码来源:onedir_runner.py
示例9: __init__
def __init__(self,Pins = [24,25,8,7],ip = "localhost", port = 1883, clientId = "MQTT2StepperMotor", user = "driver", password = "1234", prefix = "StepperMotor"):
mosquitto.Mosquitto.__init__(self,clientId)
MotorControl.__init__(self,Pins)
#Get mac adress.
mac = get_mac()
#Make a number based on pins used.
pinid = ""
for pin in Pins:
pinid += "%02i" % pin
self.prefix = prefix + "/" + str(mac) + "/" + pinid
self.ip = ip
self.port = port
self.clientId = clientId
self.user = user
self.password = password
if user != None:
self.username_pw_set(user,password)
#self.will_set( topic = "system/" + self.prefix, payload="Offline", qos=1, retain=True)
self.will_set( topic = self.prefix, payload="Offline", qos=1, retain=True)
print "Connecting to:" +ip
self.connect(ip,keepalive=10)
self.subscribe(self.prefix + "/#", 0)
self.on_connect = self.mqtt_on_connect
self.on_message = self.mqtt_on_message
#self.publish(topic = "system/"+ self.prefix, payload="Online", qos=1, retain=True)
self.publish(topic = self.prefix, payload="Online", qos=1, retain=True)
开发者ID:Anton04,项目名称:RaspPy-StepperMotor-Driver,代码行数:32,代码来源:MQTT2StepperMotor.py
示例10: __init__
def __init__(self, *argv, **kwargs):
super(RobotDaemon, self).__init__(*argv, **kwargs)
syslog.syslog(syslog.LOG_DEBUG, "%s" % config.path)
self.hwaddr = get_mac()
self.ip = get_ip()
self.uid = get_uid()
syslog.syslog(syslog.LOG_DEBUG, 'IP: %s, MAC: %s, UID: %s' % (self.ip, self.hwaddr, self.uid))
开发者ID:anka-sirota,项目名称:RFWeb,代码行数:7,代码来源:robotd.py
示例11: machineMeasureRun
def machineMeasureRun(jobFlowToM, nothing):
#debugLog('proc', 'machineMeasureRun. jobFlowToM:', jobFlowToM)
#EvalLog('{0:6f},104,start machineMeasure for jobFlows {1}'.format(time.time(), jobFlowToM))
totalCpu = psutil.cpu_percent(interval=0.05)
totalMemory = psutil.virtual_memory().total
hostId = str(get_mac())
for jobFlow in jobFlowToM:
measureResults = []
sourceJob = agentManager.sourceJobTable[jobFlow]
for name in sourceJob.measureStats:
if name == 'hostId':
measureResults.append(hostId)
elif name == 'totalCPU':
measureResults.append(totalCpu)
elif name == 'totalMemory':
measureResults.append(totalMemory)
elif name == 'IP':
measureResults.append(SelfIP.GetSelfIP())
if measureResults:
#debugLog('proc', 'measureResults:', measureResults)
(jobId, flowId) = decomposeKey(jobFlow)
(_, goFunc) = agentManager.eventAndGoFunc[jobId][flowId]
goThread = Thread(target=runGo, args=(goFunc, measureResults, jobId, flowId))
goThread.daemon = True
goThread.start()
#EvalLog('{0:6f},105,done one round of machineMeasure for jobFlows {1}'.format(time.time(), jobFlowToM))
agentManager.measureLatency += '#DoneOneRoundMachineMeasure${0:6f}'.format(time.time())
开发者ID:jiangxianliang,项目名称:hone,代码行数:27,代码来源:agentProcMeasure.py
示例12: loadDeviceId
def loadDeviceId():
mac = str(get_mac())
global deviceId
global deviceIdTable
newlines=[]
try:
deviceId=deviceIdTable[mac]
except:
try:
with open(deviceIdfilename) as f:
print("lineread")
lineread = f.readlines()
print lineread
print lineread[0].split(':')[1]
print("ESCRBI LA CONCHA DE LA LORA")
deviceIdTable[mac]=lineread[0].split(':')[1]
print(deviceIdTable[mac])
print("ESCRIBI")
deviceId=deviceIdTable[mac]
except :
deviceId=str(request_DeviceId(mac))
try:
os.remove(deviceIdfilename)
except:
print("No hace falta borrarlo, el archivo no existe")
print(deviceId)
idfile=open(deviceIdfilename,'wb+')
newlines.append(mac)
newlines.append(":")
newlines.append(deviceId)
idfile.writelines(newlines)
idfile.close()
开发者ID:cran-io,项目名称:prismetic-base,代码行数:33,代码来源:main.py
示例13: callback
def callback(ch, method, properties, body):
global sessionId
try:
sessionId = uuid.uuid1()
deviceMac = get_mac()
deviceMac = ':'.join(("%012X" % deviceMac)[i:i+2] for i in range(0, 12, 2))
logMsg = 'Fetching Speed Test request configuratin for device '+deviceMac
processMessage(logMsg, remotelog=False)
request = getSpeedTestRequest(deviceMac)
if request == None:
raise ValueError('Unable to get speed test request configuration!')
else:
rqId = request['request']['rqid']
logMsg = 'Speed device has been plugged in. Initiating speed test process...'
processMessage(logMsg, rqid=rqId)
#Retry if unsuccessful
if waitForPing("8.8.8.8", rqid=rqId) and speedtest(request):
updateRequestStatus(rqId, 3)
logMsg = 'Speed Test Completed!'
processMessage(logMsg, rqid=rqId)
else:
logMsg = 'Speed Test Unsuccessful!'
processMessage(logMsg, severity='critical', rqid=rqId)
except Exception as e:
syslogger(str(e), 'critical')
raise
开发者ID:mellanon,项目名称:speed,代码行数:31,代码来源:messageReceiver.py
示例14: __init__
def __init__(self, host, port, queue, timeout=60, conffile="/etc/notify-multiplexer/notify-multiplexer.conf"):
threading.Thread.__init__(self)
self.host = host
self.port = port
self.uid = get_mac()
self.connected = False
self.pingSem = threading.Semaphore()
self.daemon = True
self.timeout = timeout
self.queue = queue
self.config = configparser.SafeConfigParser()
self.conffile = conffile
# read config into object
try:
self.config.read(conffile)
except IOError as e:
logging.fatal("Issues loading config file: " + conf + ": " + repr(e.strerror) + ", bailing.")
exit(1)
self.context = self.makeSSLContext()
self.pingThread = NotifyMultiplexReciever._connManager._pingManager(self.pingSem, self, self.timeout)
self.pingThread.start()
logging.info("Initalized")
开发者ID:madmaze,项目名称:notify-multiplexer,代码行数:25,代码来源:libnotifymultiplex.py
示例15: __init__
def __init__(self):
self.transID = b''
self.macaddr = b''
self.op = b''
self.CIADDR = b''
self.YIADDR = b''
self.SIADDR = b''
self.GIADDR = b''
self.DHCP_Message_Type = b''
self.Subnet_Mask = b''
self.Router = b''
self.Leas_Time = b''
self.DHCP_Server = b''
self.Dns_Server = set()
mac = bin(get_mac())[2:]
if len(mac) < 48:
mac = '0' + mac
for i in range(0, 48, 8):
self.macaddr += struct.pack('!B', int(mac[i:i+8], 2))
for i in range(4):
self.transID += struct.pack('!B', randint(0, 255))
开发者ID:shane50306,项目名称:hw1,代码行数:25,代码来源:dhcp_client.py
示例16: main
def main(host,server_port):
ip = get_ip()
mac = get_mac() #Might not work correctly when having multiple MAC adresses
obj = {
"ip":ip,
"mac":mac,
}
fil = open("public.txt","rb")
t = fil.read()
fil.close()
pubkey = rsa.PublicKey.load_pkcs1(t,'PEM')
j = json.dumps(obj).encode('utf8')
aes_key = rsa.randnum.read_random_bits(128)
message = rsa.encrypt(j,pubkey)
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = host
server_port = server_port
connection.connect((host,server_port))
connection.sendall(message)
print(connection.recv(128).decode('utf8'))
connection.close()
开发者ID:hackerspace-ntnu,项目名称:PI-Status,代码行数:27,代码来源:client.py
示例17: getInformation
def getInformation(self):
# Get Platform Name
name = pal_get_platform_name()
# Get MAC Address
mac=get_mac()
mac_addr=':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))
# Get BMC Reset Reason
wdt_counter = Popen('devmem 0x1e785010', \
shell=True, stdout=PIPE).stdout.read()
wdt_counter = int(wdt_counter, 0)
wdt_counter &= 0xff00
if wdt_counter:
por_flag = 0
else:
por_flag = 1
if por_flag:
reset_reason = "Power ON Reset"
else:
reset_reason = "User Initiated Reset or WDT Reset"
# Get BMC's Up Time
uptime = Popen('uptime', \
shell=True, stdout=PIPE).stdout.read()
# Get Usage information
data = Popen('top -b n1', \
shell=True, stdout=PIPE).stdout.read()
adata = data.split('\n')
mem_usage = adata[0]
cpu_usage = adata[1]
# Get OpenBMC version
version = ""
data = Popen('cat /etc/issue', \
shell=True, stdout=PIPE).stdout.read()
#Version might start with 'v'(wedge) or 'V'(Yosemite)
if name == 'Yosemite':
ver = re.search(r'[v|V]([\w\d._-]*)\s', data)
else:
ver = re.search(r'[v|V]([\w\d._-]*)\s', data)
if ver:
version = ver.group(1)
info = {
"Description": name + " BMC",
"MAC Addr": mac_addr,
"Reset Reason": reset_reason,
"Uptime": uptime,
"Memory Usage": mem_usage,
"CPU Usage": cpu_usage,
"OpenBMC Version": version,
}
return info;
开发者ID:HengWang,项目名称:openbmc,代码行数:60,代码来源:node_bmc.py
示例18: __init__
def __init__(self, _id=get_mac(), _clean_session=True, _userdata=None, _protocol=MQTTv311):
self.id = _id
self.address = ("85.119.83.194", 1883)
self.clean_session = _clean_session
self.user_data = _userdata
self.sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.protocol = PROTOCOLS[_protocol]
开发者ID:hagaisolo,项目名称:Python-Penetration-Testing-Application,代码行数:7,代码来源:MQTT.py
示例19: packet2xml
def packet2xml(p):
root = ET.Element("Packet")
# Append the Node ID as well
nodeID = ET.SubElement(root,"nodeID")
nodeID.text = str(get_mac())
packettype1 = ET.SubElement(root, "Type")
packettype1.text = str(p.type)
packetsubtype1 = ET.SubElement(root, "Subtype")
packetsubtype1.text = str(p.subtype)
time1 = ET.SubElement(root,"Time")
time1.text = str(p.time)
addr1 = ET.SubElement(root,"Addr1")
addr1.text = str(p.addr1)
addr2 = ET.SubElement(root,"Addr2")
addr2.text = str(p.addr2)
info1 = ET.SubElement(root,"SSID")
info1.text = str(p.info)
# tree = ET.ElementTree(root)
return root
开发者ID:richardson-dp-github,项目名称:wdd,代码行数:25,代码来源:slave_sniff.py
示例20: main
def main(argv):
wsHost = 'wss://oobd.luxen.de/websockssl/'
connectID = hex(get_mac())
telnetHost = 'localhost'
telnetPort = 1234
try:
opts, args = getopt.getopt(argv,"h:c:d:p:",["host=","connect-id=","dongle-host=","dongle-port="])
except getopt.GetoptError:
print ("kadaverSim.py -h <ServerURL> -c <connectID> -d <dongleHost> -p <donglePort>")
print ("kadaverSim.py --host=<ServerURL> --connect-id=<connectID> --dongle-host<dongleHost> --dongle-port<donglePort>")
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--host"):
wsHost = arg
elif opt in ("-c", "--connect-id"):
connectID = arg
elif opt in ("-d", "--dongle-host"):
telnetHost = arg
elif opt in ("-s", "--dongle-port"):
telnetPort = int(arg)
print('connectID is "', connectID ,'"')
print('wsHost is "', wsHost ,'"')
print('telnet host is "', telnetHost ,'"')
print('telnet Port is "', telnetPort ,'"')
# will never return from this...:
mySocket= kadaverSim( wsHost, connectID , telnetHost, telnetPort)
开发者ID:stko,项目名称:oobd,代码行数:26,代码来源:kadaverSim.py
注:本文中的uuid.get_mac函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论