Sinisterly

Full Version: Personal IP checker.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
love in the beginning you were kind of getto haha
The following code is completely unnecessary
Code:
msg = print("[IP CHECK]Loading."), time.sleep(2), print("[IP CHECK]Loaded."), time.sleep(1)
(01-24-2014, 10:28 PM)3SidedSquare Wrote: [ -> ]The following code is completely unnecessary
Code:
msg = print("[IP CHECK]Loading."), time.sleep(2), print("[IP CHECK]Loaded."), time.sleep(1)
that's there for effect.