chevron_left chevron_right
Login Register invert_colors photo_library
Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Personal IP checker. filter_list
Author
Message
Personal IP checker. #1
It's basically an easy way to check your IP address without "whatismyip.com" or whatever that website is.

Import yo' shit, dawg.

We only need four imports. Pretty simple, right?

Code:
import socket
import os
import sys
import time

(PSST, I know I can use commas, I choose not to when importing modules)

Definitions

We will define events "loop" and "close".
This is where the OS module comes into play.

Code:
def loop(event):
    os.startfile("ipchecker.py"),close(begin)
    
def close(event):
    os.system('taskkill /PID %d /F' % os.getpid())

IP checker itself

This is pretty simple. All you do is load a few messages and then do an if, elif, else statement.

Code:
msg = print("[IP CHECK]Loading."), time.sleep(2), print("[IP CHECK]Loaded."), time.sleep(1)
begin = print("[IP CHECK] %s " % socket.gethostbyname(socket.gethostname())), time.sleep(1)
answer = input("[IP CHECK]Reload? ")
if answer == "yes":
    loop(begin), os.system("clear")
elif answer == "no":
    try:
        print("[IP CHECK]Process killed.")
        close(begin)
    except Exception as e:
        print(e)
else:
    print("[IP CHECK]Invalid command."), time.sleep(2), loop(begin)

EVERYBODY NOW!

This is the code all together.

Code:
import socket
import os
import sys
import time

def loop(event):
    os.startfile("ipchecker.py"),close(begin)
    
def close(event):
    os.system('taskkill /PID %d /F' % os.getpid())

msg = print("[IP CHECK]Loading."), time.sleep(2), print("[IP CHECK]Loaded."), time.sleep(1)
begin = print("[IP CHECK] %s " % socket.gethostbyname(socket.gethostname())), time.sleep(1)
answer = input("[IP CHECK]Reload? ")
if answer == "yes":
    loop(begin), os.system("clear")
elif answer == "no":
    try:
        print("[IP CHECK]Process killed.")
        close(begin)
    except Exception as e:
        print(e)
else:
    print("[IP CHECK]Invalid command."), time.sleep(2), loop(begin)

Hope you like what took my five minutes to code.

Somewhere down the road, I will be adding an IP hider.
(This post was last modified: 01-24-2014, 04:01 AM by Stocking.)

Reply




Messages In This Thread
Personal IP checker. - by Stocking - 01-24-2014, 03:40 AM
RE: Personal IP checker. - by Pidiot - 01-24-2014, 04:49 AM
RE: Personal IP checker. - by 3SidedSquare - 01-24-2014, 10:28 PM
RE: Personal IP checker. - by Stocking - 01-24-2014, 10:30 PM



Users browsing this thread: 1 Guest(s)