getmac | Platform-independent pure-Python module to get a MAC address | TCP library

 by   GhostofGoes Python Version: 0.9.4 License: MIT

kandi X-RAY | getmac Summary

kandi X-RAY | getmac Summary

getmac is a Python library typically used in Networking, TCP applications. getmac has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can install using 'pip install getmac' or download it from GitHub, PyPI.

Pure-Python package to get the MAC address of network interfaces and hosts on the local network.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              getmac has a low active ecosystem.
              It has 74 star(s) with 24 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 21 open issues and 41 have been closed. On average issues are closed in 350 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of getmac is 0.9.4

            kandi-Quality Quality

              getmac has 0 bugs and 0 code smells.

            kandi-Security Security

              getmac has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              getmac code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              getmac is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              getmac releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed getmac and discovered the below as its top functions. This is intended to give you an instant insight into getmac implemented functionality, and help decide if they suit your requirements.
            • Get the MAC address
            • Attempt to find a MAC address
            • Try one or more methods
            • Return the default interface
            • Wrapper for popen
            • Fetches an IP address using DNS
            • Call a proc
            • Return the default interface for OpenBSD
            • Search text using regex
            • Return default interface
            • Convert ip address to uuid
            • Return the default iface
            • Read a file
            • Return a uuid for a given interface
            • Read the MAC address
            • Return IP address from iputils
            • Return the macing MAC address
            • Setup the extension
            • Reads the system interface file
            Get all kandi verified functions for this library.

            getmac Key Features

            No Key Features are available at this moment for getmac.

            getmac Examples and Code Snippets

            Terminal examples
            Pythondot img1Lines of Code : 34dot img1License : Permissive (MIT)
            copy iconCopy
            getmac --help
            getmac --version
            
            # Invoking with no arguments will return MAC of the default interface
            getmac
            
            # Usage as a module
            python3 -m getmac
            
            # Interface names, IPv4/IPv6 addresses, or Hostnames can be specified
            getmac --interface ens33
            getmac  
            Python examples
            Pythondot img2Lines of Code : 17dot img2License : Permissive (MIT)
            copy iconCopy
            from getmac import get_mac_address
            eth_mac = get_mac_address(interface="eth0")
            win_mac = get_mac_address(interface="Ethernet 3")
            ip_mac = get_mac_address(ip="192.168.0.1")
            ip6_mac = get_mac_address(ip6="::1")
            host_mac = get_mac_address(hostname="loca  
            Docker
            Pythondot img3Lines of Code : 5dot img3License : Permissive (MIT)
            copy iconCopy
            docker build -f packaging/Dockerfile -t getmac .
            docker run -it getmac:latest --help
            docker run -it getmac:latest --version
            docker run -it getmac:latest -n localhost
            docker run --rm -it -v /proc/1/net/arp:/host/arp -e ARP_PATH=/host/arp getmac:latest  

            Community Discussions

            QUESTION

            Can the -eq function compare against a variable
            Asked 2022-Mar-03 at 22:54

            It appears that -eq can only compare against a literal. I am trying to compare against a variable like this. This code does not work

            ...

            ANSWER

            Answered 2022-Mar-03 at 22:54

            The /fo csv option makes getmac.exe quote the mac addresses, so the literal string value is not 00-01-02-03-04-05, but "00-01-02-03-04-05" (including the quotation marks), and they're obviously different:

            Source https://stackoverflow.com/questions/71344678

            QUESTION

            TypeError only appears when executed on Linux, works perfectly fine on Windows
            Asked 2021-Dec-22 at 13:37

            So I have this python file I created on windows:

            ...

            ANSWER

            Answered 2021-Dec-22 at 13:37

            As it become clear from the comments - the problem is with host/local ip for which getmac.get_mac_address() returns None. I also confirmed that on Linux. Looking at this issue - it's known bug/limitation of the package - it does not work for host ip on Linux. Check the discussion for more info. You can use local interface name though.

            Source https://stackoverflow.com/questions/70446595

            QUESTION

            Why i am getting the same mac address using getmac package even though i am using two different devices
            Asked 2021-Mar-07 at 19:59

            I have a webserver and the backend is written in nodejs. I am trying to get the mac address of each device accessing my website. I am using the getmac package and here is my code

            ...

            ANSWER

            Answered 2021-Mar-07 at 19:58

            I assume you are getting the mac address of the server the nodejs code is running on. It doesn't get the mac address of the client (browser).

            The opening statement at https://www.npmjs.com/package/getmac:

            This library will not run in web browsers / on the client-side / in webpack / in browserify / in angular / in react / in jQuery / in HTML. It will only run on Node.js environments, which the web browser is not.

            Source https://stackoverflow.com/questions/66520735

            QUESTION

            How can i install python modules that have spaces in between?
            Asked 2021-Mar-07 at 02:53

            I wanted to run a script that would scan my network and that script uses a awesome library called who-is-on-my-wifi. I have installed the module to run the script but i get errors from the prompt saying that it cannot detect such a module in the system. This is the script.

            ...

            ANSWER

            Answered 2021-Mar-06 at 14:46

            sometimes you can't import modules because you have installed two python versions(or conda along with it). if you have, delete one of your python versions or activate conda and try importing your module, or just try:

            Source https://stackoverflow.com/questions/66506805

            QUESTION

            Java Hibernate : findAll with include "one to one" relationship
            Asked 2021-Mar-05 at 07:55

            I want return all command record with relationship of processor table

            ...

            ANSWER

            Answered 2021-Mar-05 at 07:55

            Getter/Setters for processor are missing in the Command entity class. Add them check ,it should work.

            Source https://stackoverflow.com/questions/66480387

            QUESTION

            how to save the result of the function
            Asked 2021-Jan-07 at 08:43

            I have a function where I get the MAC of the pc and I want to save that MAC in the database, but it doesn't save me and I don't know why ..

            I use this function in another function where I update the mac field, but the result of the function does not let me save it to the database.

            ...

            ANSWER

            Answered 2021-Jan-07 at 08:43

            because you should return it in mac function

            remove this part of the function:

            Source https://stackoverflow.com/questions/65608193

            QUESTION

            Detecting BLE Device name change in Android
            Asked 2020-Dec-03 at 16:48

            We have a BLE device we are working on that outputs data via the device's name. The device is functioning properly and can be seen changing names properly using an app like nRF Connect. However, we are having a difficult time doing the same in our own Android app. We can detect the devices fine, but they will almost never move past the original names they were given.

            The code I started with has a loop that is started in onResume() that scans using a BluetoothLeScanner and the startScan() function.

            ...

            ANSWER

            Answered 2020-Dec-02 at 14:16

            I think you might simply have a problem with caching on android. See this answer here for a possible solution: https://stackoverflow.com/a/50745997/7473793

            Source https://stackoverflow.com/questions/65082349

            QUESTION

            Create a Class, with a GUI....trouble with syntax
            Asked 2020-Nov-05 at 03:44
            class ClassName:
                import tkinter, re, uuid
                from tkinter.constants import *
                import tkinter.messagebox
                import socket, os, subprocess, multiprocessing, sys
                from getmac import get_mac_address as gma
                import getmac, paramiko
                import gpio
                import time, requests, sudo
                from subprocess import Popen
             
                def __init__(self):
                    self.p = paramiko.SSHClient()
                    self.p.set_missing_host_key_policy(paramiko.AutoAddPolicy())   
                    self.p.connect("X.0.0.X", port = , username=" ", password=" ")
            
                def get_ports(self):
                    tkinter.messagebox.showinfo("Configure Software", "Configure Access")
            
                    button3 = tkinter.Button(frame,text="Configure", fg="pink", bg="white", command=get_ports)
                    button3.pack(side=LEFT)
                    
                    tkinter.messagebox.showinfo("Client/Server Information", "Lets Be Nosey")
                
                    button4 = tkinter.Button(frame,text=" Client/Server Information", command=get_ports)
                    button4.pack(side=LEFT)
                
                    exec(open('path').read(), globals())
            
                def pinger(self, job_q, results_q):
                    """
                    Do Ping
                    :param job_q:
                    :param results_q:
                    :return:
                    """
                    DEVNULL = open(os.devnull, 'w')
                    while True:
            
                        ip = job_q.get()
            
                        if ip is None:
                            break
            
                        try:
                            subprocess.check_call(['ping', '-c1', ip],
                                                stdout=DEVNULL)
                            results_q.put(ip)
                        except:
                            pass
            
                def get_my_ip(self):
                    """
                    Find my IP address
                    :return:
                    """
                    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                    s.connect(("8.8.8.8", 80))
                    ip = s.getsockname()[0]
                    s.close()
                    return ip
            
                def map_network(self, pool_size=255):
                    """
                    Maps the network
                    :param pool_size: amount of parallel ping processes
                    :return: list of valid ip addresses
                    """
            
                    ip_list = list()
            
                    ip_parts = get_my_ip().split('.')
                    base_ip = ip_parts[0] + '.' + ip_parts[1] + '.' + ip_parts[2] + '.'
            
                    jobs = multiprocessing.Queue()
                    results = multiprocessing.Queue()
            
                    pool = [multiprocessing.Process(target=pinger, args=(jobs, results)) for i in range(pool_size)]
            
                    for p in pool:
                        p.start()
            
                    for i in range(1, 255):
                        jobs.put(base_ip + '{0}'.format(i))
            
                    for p in pool:
                        jobs.put(None)
            
                    for p in pool:
                        p.join()
            
                    while not results.empty():
                        ip = results.get()
                        ip_list.append(ip)
            
                    return ip_list
            
                def test_log(self):
                    print('test log')
                    print('Mapping...')
                    lst = map_network()
                    print(lst)
                    addresses = subprocess.check_output(['arp', '-a'])
                    print(addresses)
            
                def ssh_connect(self):
                    ssh = paramiko.SSHClient()
                    ssh.load_system_host_keys()
                    ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
                    ssh.connect("X.0.0.X", port, "user", "password")
                    chan=ssh.get_transport().open_session()
                    chan.get_pty()
                    f = chan.makefile()
                    chan.exec_command("sudo dmesg")
                    chan.send("password\n")
                    print(f.read())
                    ssh.close()
                    pass
            
                def raspi_connecter(self):
                    print("Below is the output from the shell script in terminal")
                    # subprocess.call('ssh user@X.0.0.X', shell=True)
                    proc = subprocess.Popen('ssh user@X.0.0.X', shell=True)
                    try:
                        outs, errs = proc.communicate(timeout=8)
                            # print(f.returncode)
                    except TimeoutError:
                        proc.kill()
            
                        cmd = ['sh commands3.sh']
                        f = subprocess.Popen(cmd, stdout=subprocess.PIPE)
                        for line in f.stdout:
                            print(line)
                            f.wait()
            
                def keypad_tests(self):
                    stdin, stdout, stderr = self.p.exec_command('sudo nano /etc/hostname')
                    opt2 = stdout.readlines()
                    opt2 = "".join(opt2)
                    # sudo journalctl -u spiderentry.service | sudo tee ../../full_log.sh 
                    print(opt2)
                    input("press enter to continue")
            
                # sudo touch and sudo tee (wipe the file (X_log) and recreate/write upon command execution)
            
                        
            
            
                if __name__=='__main__':
                    tk = tkinter.Tk()
                    
            
                    frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
                    frame.pack(fill=BOTH,expand=100)
            
                    label = tkinter.Label(frame, text="GUI IP/Port Scanner")
                    label.pack(fill=X, expand=100)
                    
                    button1 = tkinter.Button(frame,text="Exit",fg="red", bg="black", command=tk.destroy)
                    button1.pack(side=LEFT)
                    
                    button2 = tkinter.Button(frame,text="Start", fg="blue", bg="green", command=map_network)
                    button2.pack(side=LEFT)
                    button5 = tkinter.Button(frame, text="Port Scanner", command=test_log)
                    button5.pack(side=LEFT)
                    button6 = tkinter.Button(frame, text="connect keypad", command=raspi_connecter)
                    button6.pack(side=LEFT)
                    button7 = tkinter.Button(frame, text= "run tests", command= keypad_tests)
                    button7.pack(side=LEFT)
            
                    tk.mainloop()
            
                # release the function (threading, multiprocessing)
                # # open file and pull lines out commands.sh
            
            ...

            ANSWER

            Answered 2020-Nov-05 at 02:01

            Your issue is that you've put all your import statements inside your class. That makes the variables that get created class variables, which you probably don't want. You're not accessing them as class variables later, so it doesn't look like you intend to be doing this. Furthermore, using a wildcard import like from tkinter.constants import * is not allowed anywhere but at the top level.

            The obvious fix is to move the imports outside the class:

            Source https://stackoverflow.com/questions/64686238

            QUESTION

            How to get several eternet mac address by python at windows?
            Asked 2020-Oct-08 at 03:04

            I'm trying to get several eternet mac addresses by python.
            I tried this python code, and it works to get the first mac address.

            ...

            ANSWER

            Answered 2020-Oct-08 at 02:20

            QUESTION

            BLE with RPI, wrong endpoint ID selected
            Asked 2020-Sep-18 at 20:31

            Trying to communicate with a BLE device (smart lamp).

            I use the following dependency:

            ...

            ANSWER

            Answered 2020-Sep-16 at 22:42

            gattool is one of the eight tools that have been deprecated by BlueZ.

            To debug this I would advise using bluetoothctl to workout what the correct paths are for the connected device. A session might look like this:

            Source https://stackoverflow.com/questions/63926205

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install getmac

            Stable release from PyPI.

            Support

            All or almost all features should work on "supported" platforms. While other versions of the same family or distro may work, they are untested and may have bugs or missing features.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install getmac

          • CLONE
          • HTTPS

            https://github.com/GhostofGoes/getmac.git

          • CLI

            gh repo clone GhostofGoes/getmac

          • sshUrl

            git@github.com:GhostofGoes/getmac.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular TCP Libraries

            masscan

            by robertdavidgraham

            wait-for-it

            by vishnubob

            gnet

            by panjf2000

            Quasar

            by quasar

            mumble

            by mumble-voip

            Try Top Libraries by GhostofGoes

            ADLES

            by GhostofGoesPython

            Astolfo

            by GhostofGoesPython

            sneaky-scripts

            by GhostofGoesPowerShell

            cgoes-cminus-compiler

            by GhostofGoesC

            macaddress

            by GhostofGoesPython