Created
May 6, 2020 00:00
-
-
Save ptigas/efafd7e2fcbdb4aab795bd36e13d7409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import platform | |
import requests | |
import os | |
import subprocess | |
def get_key(): | |
if 'Darwin' in platform.platform(): | |
url = 'https://www.roboti.us/getid/getid_osx' | |
elif 'Linux' in platform.platform(): | |
url = 'https://www.roboti.us/getid/getid_linux' | |
else: | |
pass | |
f = requests.get(url) | |
open('getid', 'wb').write(f.content) | |
os.system('chmod a+x getid') | |
from subprocess import Popen, PIPE | |
p = Popen(['./getid | sed "4q;d" > res.txt'], stdin=PIPE, stderr=PIPE, shell=True) | |
p.communicate(input='\n'.encode()) | |
os.system('rm getid') | |
with open('res.txt') as f: key = f.readlines()[0].rstrip().strip() | |
os.system('rm res.txt') | |
return key | |
print(get_key()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment