示例#1
0
try:
    import simplejson as json
except:
    import json
import sys

import requests
from clint.textui import puts, columns, colored
import komandr

from b2tool.conf import BASE_URL_V2, get_credentials
from b2tool import __projectname__


_pullrequest = komandr.prog(prog='{0} pull request'.format(__projectname__))

USERNAME, PASSWORD = get_credentials()

# Method has implements
# GETrepositories/{owner}/{repo_slug}/pullrequests/
# POSTrepositories/{owner}/{repo_slug}/pullrequests/
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}
# PUTrepositories/{owner}/{repo_slug}/pullrequests/{id}
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}
# GETrepositories/{owner}/{repo_slug}/pullrequests/activity
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/activity
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/commits
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/patch
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/diff
# POSTrepositories/{owner}/{repo_slug}/pullrequests/{id}/accept
示例#2
0
from b2tool.rules import Pull

try:
    import simplejson as json
except:
    import json
import sys

import requests
from clint.textui import puts, columns, colored
import komandr

from b2tool.conf import BASE_URL_V2, get_credentials
from b2tool import __projectname__

_pullrequest = komandr.prog(prog='{0} pull request'.format(__projectname__))

USERNAME, PASSWORD = get_credentials()

# Method has implements
# GETrepositories/{owner}/{repo_slug}/pullrequests/
# POSTrepositories/{owner}/{repo_slug}/pullrequests/
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}
# PUTrepositories/{owner}/{repo_slug}/pullrequests/{id}
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}
# GETrepositories/{owner}/{repo_slug}/pullrequests/activity
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/activity
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/commits
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/patch
# GETrepositories/{owner}/{repo_slug}/pullrequests/{id}/diff
# POSTrepositories/{owner}/{repo_slug}/pullrequests/{id}/accept
示例#3
0
import ConfigParser
import sys

import komandr

import requests
from b2tool import __projectname__
from b2tool.conf import CFGFILE, BASE_URL_V1


_auth = komandr.prog(prog='{0} auth'.format(__projectname__))

@komandr.command
@komandr.arg('cmd', 'cmd', choices=['login', 'logout'], help="Available auth subcommands. Use <subcommand> -h to see more.")
def auth(cmd):
    _auth.execute(sys.argv[2:])

@_auth.command
@_auth.arg('username', required=True, type=str, help='')
@_auth.arg('password', required=True, type=str, help='')
def login(username=None, password=None):

    path = BASE_URL_V1 + 'user/'
    res = requests.get(path, auth=(username, password))
    print 'Logging...'
    if res.status_code == 200:
        with open(CFGFILE, 'wb') as cfg:
            conf = ConfigParser.ConfigParser()
            conf.add_section('AUTH')
            conf.set('AUTH', 'username', username)
            conf.set('AUTH', 'password', password)
示例#4
0
import ConfigParser
import sys

import komandr

import requests
from b2tool import __projectname__
from b2tool.conf import CFGFILE, BASE_URL_V1

_auth = komandr.prog(prog='{0} auth'.format(__projectname__))


@komandr.command
@komandr.arg(
    'cmd',
    'cmd',
    choices=['login', 'logout'],
    help="Available auth subcommands. Use <subcommand> -h to see more.")
def auth(cmd):
    _auth.execute(sys.argv[2:])


@_auth.command
@_auth.arg('username', required=True, type=str, help='')
@_auth.arg('password', required=True, type=str, help='')
def login(username=None, password=None):

    path = BASE_URL_V1 + 'user/'
    res = requests.get(path, auth=(username, password))
    print 'Logging...'
    if res.status_code == 200: