Last active
December 16, 2015 11:28
-
-
Save caruccio/5427069 to your computer and use it in GitHub Desktop.
Gists para o blog
This file contains 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
from hammock import Hammock as Getup | |
username, password = 'mateus.caruccio@getupcloud.com', 'minha_senha' | |
getup = Getup('https://broker.getupcloud.com/broker/rest', auth=(username, password)) |
This file contains 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
# | |
# Busca a lista de dominios (so temos um por enquanto) | |
# | |
domains = getup.domains.GET() | |
for domain in domains.json()['data']: | |
print domain['id'] | |
# Saida: | |
# caruccio | |
# | |
# Busca a lista de aplicacoes do dominio | |
# | |
apps = getup.domains(domain['id']).applications.GET() | |
# | |
# Vamos mostrar algumas informacoes uteis sobre os apps | |
# | |
print '%-7s | %-10s | %-10s' % ('name', 'framework', 'url') | |
print '-' * 33 | |
for app in apps.json()['data']: | |
print '%s: framework = %s, url = %s' % (app['name'], app['framework'], app['app_url']) | |
# Saida: | |
# name | framework | url | |
# --------------------------------- | |
# longrun: framework = php-5.3, url = http://longrun-caruccio.getup.io/ | |
# blog: framework = php-5.3, url = http://blog-caruccio.getup.io/ |
This file contains 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
>>> from hammock import Hammock as Getup | |
>>> getup = Getup('https://broker.getupcloud.com/broker/rest') | |
>>> res = getup.api.GET() | |
>>> res | |
<Response [200]> | |
>>> res.url | |
u'https://broker.getupcloud.com/broker/rest/api' | |
>>> res.status_code | |
200 | |
>>> json = res.json() | |
>>> json | |
{u'status': u'ok', u'type': u'links', u'messages': [], u'version': u'1.3',... |
This file contains 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
>>> from hammock import Hammock as Github | |
>>> github = Github('https://github.com') | |
>>> github | |
https://github.com | |
>>> page = github.kadirpekel.hammock.GET() | |
>>> page | |
<Response [200]> | |
>>> page.url | |
u'https://github.com/kadirpekel/hammock' | |
>>> page.status_code | |
200 | |
>>> page.text[0:30] | |
u' \n\n\n<!DOCTYPE html>\n<html>\n ' |
This file contains 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
$ sudo pip install requests==0.13.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment