summaryrefslogtreecommitdiff
path: root/lib.py
blob: 4982e329d2586a24a8df01c78beab8b842b621ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import sys

import cliapp
from yarnutils import *

import yarnhelper

helper = yarnhelper.YarnHelper()

srcdir = os.environ['SRCDIR']
datadir = os.environ['DATADIR']

vars = Variables(datadir)



def gitano(user, args, stdin=None):
    server = os.environ['GITANO_SERVER']
    kwargs = {
        'stderr': subprocess.STDOUT,
        'ssh_options': [
            '-oPasswordAuthentication=no',
            '-oIdentitiesOnly=yes',
            '-i', self.get_user_ssh_key(user),
        ],
    }
    if stdin is not None:
        kwargs['feed_stdin'] = stdin
    return cliapp.ssh_runcmd(
        'git@{}'.format(server),
        args.split(),
        **kwargs)



def gitano_confirm_with_token(prefix, which):
    try:
        output = gitano(None, '{} {}'.format(prefix, which))
    except cliapp.AppException:
        pass
    else:
        last_line = output.splitlines()[-1]
        token = last_line.split()[-1]
        gitano(None, '{} {} {}'.format(prefix, which, token))