Skip to content

Instantly share code, notes, and snippets.

@ptigas
Created May 6, 2020 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptigas/efafd7e2fcbdb4aab795bd36e13d7409 to your computer and use it in GitHub Desktop.
Save ptigas/efafd7e2fcbdb4aab795bd36e13d7409 to your computer and use it in GitHub Desktop.
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