Skip to content

Commit 866f47d

Browse files
committed
add new command
1 parent d1b18ae commit 866f47d

24 files changed

+258
-52
lines changed

lain_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
__version__ = '2.3.11'
4+
__version__ = '2.4.0'

lain_cli/auth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import re
44
import requests
5-
from urllib import urlencode
6-
from urlparse import urlparse, parse_qs
5+
from urllib.parse import urlencode, urlparse, parse_qs
76

87
from lain_sdk.yaml.conf import user_config
98
import lain_sdk.mydocker as docker

lain_cli/backup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def jobs(cls, phase):
3434
route = "api/v2/app/%s/cron/jobs" % appname
3535
data = cls._request('GET', phase, route, None)
3636
if data:
37-
print json.dumps(data, indent=2)
37+
print((json.dumps(data, indent=2)))
3838

3939
@classmethod
4040
@arg('phase', nargs=1, help="lain cluster phase id, can be added by lain config save")
@@ -50,9 +50,9 @@ def list(cls, phase, proc, path):
5050
route = "api/v2/app/%s/proc/%s/backups/%s?open=true" % (appname, proc[0], path[0])
5151
data = cls._request('GET', phase[0], route, None)
5252
if data:
53-
print "%-10sFILENAME" % "SIZE"
53+
print(("%-10sFILENAME" % ("SIZE")))
5454
for item in data:
55-
print "%-10s%s%s" % (item['size'], item['name'], '/' if item['dir'] else '')
55+
print(("%-10s%s%s" % (item['size'], item['name'], '/' if item['dir'] else '')))
5656

5757
@classmethod
5858
@arg('phase', nargs=1, help="lain cluster phase id, can be added by lain config save")
@@ -67,7 +67,7 @@ def get(cls, phase, proc, volume):
6767
route = "api/v2/app/%s/proc/%s/backups?volume=%s" % (appname, proc[0], volume[0])
6868
data = cls._request('GET', phase[0], route, None)
6969
if data:
70-
print json.dumps(data, indent=2)
70+
print((json.dumps(data, indent=2)))
7171

7272
@classmethod
7373
@arg('phase', nargs=1, help="lain cluster phase id, can be added by lain config save")
@@ -82,7 +82,7 @@ def delete(cls, phase, proc, files):
8282
route = "api/v2/app/%s/proc/%s/backups/actions/delete" % (appname, proc[0])
8383
data = cls._request('POST', phase[0], route, {'files': files})
8484
if data:
85-
print data
85+
print(data)
8686

8787
@classmethod
8888
@arg('phase', nargs=1, help="lain cluster phase id, can be added by lain config save")
@@ -143,7 +143,7 @@ def records(cls, phase, rid, num=10):
143143
route += "?total=%d" % num
144144
data = cls._request('GET', phase[0], route, None)
145145
if data:
146-
print json.dumps(data, indent=2)
146+
print((json.dumps(data, indent=2)))
147147

148148
@classmethod
149149
@arg('phase', nargs=1, help="lain cluster phase id, can be added by lain config save")
@@ -157,7 +157,7 @@ def run(cls, phase, id):
157157
route = "api/v2/app/%s/cron/jobs/%s/actions/run" % (appname, id[0])
158158
data = cls._request('POST', phase[0], route, None)
159159
if data:
160-
print data
160+
print(data)
161161

162162
@classmethod
163163
def _request(cls, method, phase, url, data):

lain_cli/clear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def clear(without=""):
1515

1616
yml = lain_yaml(ignore_prepare=True)
1717
without_phases = without.split(',')
18-
for name in yml.img_names.values():
18+
for name in list(yml.img_names.values()):
1919
if docker.get_phase(name) not in without_phases:
2020
docker.remove_image(name)

lain_cli/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ def show(cls):
2727
"""
2828
configs = user_config.get_config()
2929
hide_keys = [SSO_TOKEN_KEY, SSO_REFRESH_TOKEN_KEY]
30-
for k, v in configs.iteritems():
30+
for k, v in configs.items():
3131
if not isinstance(v, dict):
3232
continue
3333
for key in hide_keys:
34-
if v.has_key(key):
34+
if key in v:
3535
v.pop(key)
36-
print json.dumps(configs, sort_keys=True, indent=4)
36+
print((json.dumps(configs, sort_keys=True, indent=4)))
3737

3838
@classmethod
3939
@arg('prop', help="property for the special phase, e.g: domain, sso_url")

lain_cli/dashboard.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ def print_workflows():
5757
def render_repos(repos):
5858
repos.sort()
5959
for repo in repos:
60-
print("{} ".format(repo)),
60+
print(("{} ".format(repo)), end=' ')
6161

6262

6363
def render_apps(apps, sort_type):
6464
apps.sort(key=attrgetter(sort_type))
6565
for app in apps:
66-
print("{:<30} {:<20} {:<60} {:<10}".format(
67-
app.appname, app.apptype, app.metaversion, app.state))
66+
print(("{:<30} {:<20} {:<60} {:<10}".format(
67+
app.appname, app.apptype, app.metaversion, app.state)))
6868

6969

7070
def print_available_repos(console, auth_header):
@@ -83,8 +83,8 @@ def print_available_apps(console, auth_header, sort_type):
8383
apps_url = "http://%s/api/v1/apps/" % console
8484
apps_res = requests.get(apps_url, headers=auth_header)
8585
info('Available apps are :')
86-
print("{:<30} {:<20} {:<60} {:<10}".format(
87-
"Appname", "AppType", "MetaVersion", "State"))
86+
print(("{:<30} {:<20} {:<60} {:<10}".format(
87+
"Appname", "AppType", "MetaVersion", "State")))
8888
if apps_res.status_code == 200:
8989
apps = apps_res.json()["apps"]
9090
render_apps([AppInfo.new(app) for app in apps], sort_type)

lain_cli/deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def deploy_proc(proc, appname, console, auth_header, output):
136136
result = deploy_r.json()
137137
msg = result.pop('msg', '')
138138
if msg:
139-
print msg.decode('string_escape')
139+
print((msg.decode('string_escape')))
140140
info("proc status: ")
141141
render_proc_status(result.get('proc'), output=output)
142142
except Exception:

lain_cli/lain.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
from lain_cli.backup import BackupCommands
4141
from lain_cli.maintainer import MaintainerCommands
4242

43+
from lain_cli.new import new
44+
4345
from lain_cli.utils import exit_gracefully
4446

4547
logging.getLogger("requests").setLevel(logging.WARNING)
@@ -49,7 +51,7 @@
4951

5052
one_level_commands = [
5153
appversion, attach, build, check, clear, dashboard, debug,
52-
deploy, enter, login, logout, meta, prepare, prepare_update,
54+
deploy, enter, login, logout, meta, new, prepare, prepare_update,
5355
ps, push, refresh, reposit, rm, rmi, run, sync,
5456
scale, stop, tag, test, undeploy, update, validate, version
5557
]

lain_cli/login.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def login(phase, cid=None, secret=None, redirect_uri=None):
3232
"""
3333

3434
check_phase(phase)
35-
username = raw_input('SSO Username:')
35+
username = input('SSO Username:')
3636
password = getpass.getpass('SSO Password:')
3737
sso_login_success = sso_login(phase, cid, secret, redirect_uri, username, password)
3838
if not sso_login_success:

lain_cli/logout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def logout(phase):
1717
domain = get_domain(phase)
1818
logout_success = SSOAccess.clear_token(phase)
1919
if logout_success:
20-
docker.logout('registry.%s'%domain)
20+
docker.logout('registry.{}'.format(domain))
2121
info("Logout successfully!")
2222
else:
2323
warn('Logout failed!')

0 commit comments

Comments
 (0)