Guest User

A Python tool I made

a guest
Jun 19th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.77 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import time
  5. import math
  6. import subprocess as sp
  7. import json
  8. import urllib
  9. import platform
  10. import sys
  11. import smtplib
  12.  
  13. os = platform.system()
  14. pcname = platform.node()
  15.  
  16.  
  17. def main():
  18.     cls()
  19.     print("1) Calculator")
  20.     print("2) IP Tools")
  21.     print("3) Binary")
  22.     sin = input('>>> ')
  23.     if sin == 1:
  24.         calc()
  25.     if sin == 2:
  26.         ipt()
  27.     if sin == 3:
  28.         bint()
  29.  
  30. def calc():
  31.     def add():
  32.         cls()
  33.         print("Type Number 1")
  34.         n1 = input(">>> ")
  35.         print("Type Number 2")
  36.         n2 = input(">>> ")
  37.         tot = n1+n2
  38.         print(str(n1)+" + "+str(n2)+" = "+str(tot))
  39.     def sub():
  40.         cls()
  41.         print("Type Number 1")
  42.         n1 = input(">>> ")
  43.         print("Type Number 2")
  44.         n2 = input(">>> ")
  45.         tot = n1-n2
  46.         print(str(n1)+" - "+str(n2)+" = "+str(tot))        
  47.     def mul():
  48.         cls()
  49.         print("Type Number 1")
  50.         n1 = input(">>> ")
  51.         print("Type Number 2")
  52.         n2 = input(">>> ")
  53.         tot = n1*n2
  54.         print(str(n1)+" x "+str(n2)+" = "+str(tot))
  55.     def div():
  56.         cls()
  57.         print("Type Number 1")
  58.         n1 = input(">>> ")
  59.         print("Type Number 2")
  60.         n2 = input(">>> ")
  61.         tot = n1/n2
  62.         r = n1%n2
  63.         print(str(n1)+" / "+str(n2)+" = "+str(tot)+" R"+str(r))
  64.     cls()
  65.     print '1) Addition'
  66.     print '2) Subtraction'
  67.     print '3) Multiplacation'
  68.     print '4) Division'
  69.     cin = input('>>> ')
  70.     if cin == 1:
  71.         add()
  72.     if cin == 2:
  73.         sub()
  74.     if cin == 3:
  75.         mul()
  76.     if cin == 4:
  77.         div()
  78.        
  79.        
  80. def ipt():
  81.     cls()
  82.     print "1) Whats my IP"
  83.     print "2) IP to Location"
  84.     ipti = input('>>> ')
  85.  
  86.     if ipti == 1:
  87.         cls()
  88.         ip = urllib.urlopen('http://www.networksecuritytoolkit.org/nst/tools/ip.php').read()
  89.         print('Your IP is '+ip)
  90.         rq()
  91.        
  92.     if ipti == 2:
  93.         cls()
  94.         print("1) My Location")
  95.         print("2) IP to Location")
  96.        
  97.         uin = input(">>> ")
  98.        
  99.         if uin == 1:
  100.             cls()
  101.             ip = urllib.urlopen("http://www.networksecuritytoolkit.org/nst/tools/ip.php").read()
  102.             jipd = "http://ipinfo.io/"+ip+"/geo"
  103.             jd = json.load(urllib.urlopen(jipd))
  104.             print("You live in "+jd["city"]+", "+jd["region"]+" "+jd["country"])
  105.             rq()
  106.         if uin == 2:
  107.             cls()
  108.             print("Type IP to get Location of ")
  109.             ip = raw_input(">>> ")
  110.             jipd = "http://ipinfo.io/"+ip+"/geo"
  111.             jd = json.load(urllib.urlopen(jipd))
  112.             print("You live in "+jd["city"]+", "+jd["region"]+" "+jd["country"])
  113.             rq()
  114.  
  115. def bint():
  116.     cls()
  117.     print("1) Binary to text")
  118.     print("2) Text to binary")
  119.     uin = input(">>> ")        
  120.    
  121.     if uin == 1:
  122.         cls()
  123.         print("Binary to convert")
  124.         binaryt = input(">>> ")
  125.         print(''.join(chr(int(binaryt[i:i+8], 2)) for i in xrange(0, len(bin_text), 8)))
  126.         rq()
  127.     if uin == 2:
  128.         cls()
  129.         print("Text to convert")
  130.         raw = raw_input(">>> ")
  131.         print(''.join('{:08b}'.format(ord(c)) for c in raw))
  132.         rq()
  133.        
  134. def rq():
  135.     cls()
  136.     print 'Do you want to restart?(y/n)'
  137.     gbq = raw_input('>>>')
  138.     a = gbq.lower
  139.     cls()
  140.     if a == 'y' or 'yes':
  141.         start()
  142.     if a == 'n' or 'no':
  143.         import sys
  144.         print 'Exiting'
  145.         sys.exit(0)
  146.         exit()
  147.  
  148. def cls():
  149.     if os == 'Windows' or 'Vista' or 'XP':
  150.         sp.call('cls', shell=True)
  151.     elif os == 'Linux' or 'Linux2' or 'Darwin':
  152.         sp.call('clear', shell=True)
  153.     else:
  154.         print '\nUnable to clear screen!'
  155.  
  156.  
  157. main()
Advertisement
Add Comment
Please, Sign In to add comment