materials-commons-cli 2.1.1__tar.gz → 2.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/PKG-INFO +4 -2
- materials_commons-cli-2.1.2/materials_commons/cli/__init__.py +1 -0
- materials_commons-cli-2.1.2/materials_commons/cli/parser.py +185 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/remote.py +23 -15
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/up.py +2 -2
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/PKG-INFO +4 -2
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/entry_points.txt +1 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/requires.txt +1 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/setup.py +2 -1
- materials_commons-cli-2.1.1/materials_commons/cli/__init__.py +0 -1
- materials_commons-cli-2.1.1/materials_commons/cli/parser.py +0 -130
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/LICENSE +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/README.md +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/LICENSE.txt +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/cloned_project.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/exceptions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/file_functions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/functions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/globus.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/list_objects.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/print_formatter.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/sqltable.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/__init__.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/clone.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/config.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/dataset.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/down.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/expt.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/fetch.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/globus.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/init.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/ls.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/mkdir.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/mv.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/proj.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/rm.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/versions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/tmp_functions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/tree_functions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/treedb.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/user_config.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/SOURCES.txt +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/dependency_links.txt +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/not-zip-safe +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/top_level.txt +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/setup.cfg +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_api.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_functions.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_dataset.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_down.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_mkdir.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_mv.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_proj.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_rm.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_mc_up.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_treecompare_no_cache.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_treecompare_with_cache.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_treedb.py +0 -0
- {materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_user_config.py +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: materials_commons-cli
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.2
|
|
4
4
|
Summary: Materials Commons CLI
|
|
5
5
|
Home-page: https://materials-commons.github.io/materials-commons-cli/html/index.html
|
|
6
6
|
Author: Materials Commons development team
|
|
7
|
-
Author-email: materials-commons-
|
|
7
|
+
Author-email: materials-commons-help@umich.edu
|
|
8
8
|
License: MIT
|
|
9
9
|
Keywords: materials science mc materials-commons prisms
|
|
10
|
+
Platform: UNKNOWN
|
|
10
11
|
Classifier: Development Status :: 4 - Beta
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -21,3 +22,4 @@ This package contains the materials_commons.cli module. This module is an interf
|
|
|
21
22
|
Commons web site, https://materialscommons.org/, or a similar site based on the
|
|
22
23
|
Materials Commons code (https://github.com/materials-commons/materialscommons), and intend to use these
|
|
23
24
|
tools in that context.
|
|
25
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.1.2'
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from datetime import datetime, timedelta
|
|
6
|
+
from io import StringIO
|
|
7
|
+
|
|
8
|
+
import materials_commons.api as mcapi
|
|
9
|
+
import pkg_resources
|
|
10
|
+
import requests
|
|
11
|
+
|
|
12
|
+
import materials_commons.cli.functions as clifuncs
|
|
13
|
+
from materials_commons.cli.exceptions import MCCLIException, MissingRemoteException, \
|
|
14
|
+
MultipleRemoteException, NoDefaultRemoteException
|
|
15
|
+
from materials_commons.cli.subcommands.clone import clone_subcommand
|
|
16
|
+
from materials_commons.cli.subcommands.config import config_subcommand
|
|
17
|
+
from materials_commons.cli.subcommands.dataset import DatasetSubcommand
|
|
18
|
+
from materials_commons.cli.subcommands.down import down_subcommand
|
|
19
|
+
from materials_commons.cli.subcommands.expt import ExptSubcommand
|
|
20
|
+
from materials_commons.cli.subcommands.fetch import fetch_subcommand
|
|
21
|
+
# from materials_commons.cli.subcommands.samp import SampSubcommand
|
|
22
|
+
from materials_commons.cli.subcommands.globus import globus_subcommand
|
|
23
|
+
from materials_commons.cli.subcommands.init import init_subcommand
|
|
24
|
+
from materials_commons.cli.subcommands.ls import ls_subcommand
|
|
25
|
+
from materials_commons.cli.subcommands.mkdir import mkdir_subcommand
|
|
26
|
+
from materials_commons.cli.subcommands.mv import mv_subcommand
|
|
27
|
+
# from materials_commons.cli.subcommands.proc import ProcSubcommand
|
|
28
|
+
from materials_commons.cli.subcommands.proj import ProjSubcommand
|
|
29
|
+
from materials_commons.cli.subcommands.remote import remote_subcommand
|
|
30
|
+
from materials_commons.cli.subcommands.rm import rm_subcommand
|
|
31
|
+
from materials_commons.cli.subcommands.up import up_subcommand
|
|
32
|
+
from materials_commons.cli.subcommands.versions import versions_subcommand
|
|
33
|
+
from materials_commons.cli.user_config import Config
|
|
34
|
+
|
|
35
|
+
standard_usage = [
|
|
36
|
+
{'name': 'remote', 'desc': 'List servers', 'subcommand': remote_subcommand},
|
|
37
|
+
{'name': 'proj', 'desc': 'List projects', 'subcommand': ProjSubcommand()},
|
|
38
|
+
{'name': 'dataset', 'desc': 'List datasets', 'subcommand': DatasetSubcommand()},
|
|
39
|
+
{'name': 'expt', 'desc': 'List experiments', 'subcommand': ExptSubcommand()},
|
|
40
|
+
{'name': 'init', 'desc': 'Initialize a new project', 'subcommand': init_subcommand},
|
|
41
|
+
{'name': 'clone', 'desc': 'Clone an existing project', 'subcommand': clone_subcommand},
|
|
42
|
+
{'name': 'ls', 'desc': 'List directory contents', 'subcommand': ls_subcommand},
|
|
43
|
+
{'name': 'mkdir', 'desc': 'Make directories', 'subcommand': mkdir_subcommand},
|
|
44
|
+
{'name': 'rm', 'desc': 'Remove files and directories', 'subcommand': rm_subcommand},
|
|
45
|
+
{'name': 'mv', 'desc': 'Move files', 'subcommand': mv_subcommand},
|
|
46
|
+
{'name': 'fetch', 'desc': 'Remote data fetching and configuration', 'subcommand': fetch_subcommand},
|
|
47
|
+
{'name': 'up', 'desc': 'Upload files', 'subcommand': up_subcommand},
|
|
48
|
+
{'name': 'down', 'desc': 'Download files', 'subcommand': down_subcommand},
|
|
49
|
+
{'name': 'globus', 'desc': 'Manage Globus uploads and downloads', 'subcommand': globus_subcommand},
|
|
50
|
+
{'name': 'versions', 'desc': 'List file versions', 'subcommand': versions_subcommand},
|
|
51
|
+
# {'name': 'proc', 'desc': 'List processes', 'subcommand': ProcSubcommand()},
|
|
52
|
+
# {'name': 'samp', 'desc': 'List samples', 'subcommand': SampSubcommand()},
|
|
53
|
+
{'name': 'config', 'desc': 'Configure `mc`', 'subcommand': config_subcommand}
|
|
54
|
+
]
|
|
55
|
+
standard_interfaces = {d['name']: d for d in standard_usage}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def make_parser():
|
|
59
|
+
usage_help = StringIO()
|
|
60
|
+
usage_help.write("mc <command> [<args>]\n\n")
|
|
61
|
+
usage_help.write("The standard mc commands are:\n")
|
|
62
|
+
|
|
63
|
+
for name, interface in standard_interfaces.items():
|
|
64
|
+
usage_help.write(" {:10} {:40}\n".format(name, interface['desc']))
|
|
65
|
+
|
|
66
|
+
parser = argparse.ArgumentParser(
|
|
67
|
+
description='Materials Commons command line interface',
|
|
68
|
+
usage=usage_help.getvalue())
|
|
69
|
+
parser.add_argument('command', help='Subcommand to run')
|
|
70
|
+
|
|
71
|
+
return parser
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
CLI_VERSION_CACHE_FILE = os.path.expanduser('~/.materialscommons/.cli-version-cache.json')
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def should_check_version():
|
|
78
|
+
try:
|
|
79
|
+
if os.path.exists(CLI_VERSION_CACHE_FILE):
|
|
80
|
+
with open(CLI_VERSION_CACHE_FILE) as f:
|
|
81
|
+
cache = json.load(f)
|
|
82
|
+
last_check = datetime.fromisoformat(cache['last_check'])
|
|
83
|
+
# Only check once per day
|
|
84
|
+
if datetime.now() - last_check < timedelta(days=1):
|
|
85
|
+
return False
|
|
86
|
+
except Exception:
|
|
87
|
+
pass
|
|
88
|
+
return True
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def update_version_cache():
|
|
92
|
+
try:
|
|
93
|
+
with open(CLI_VERSION_CACHE_FILE, 'w') as f:
|
|
94
|
+
json.dump({
|
|
95
|
+
'last_check': datetime.now().isoformat()
|
|
96
|
+
}, f)
|
|
97
|
+
except Exception:
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def check_package_version():
|
|
102
|
+
if not should_check_version():
|
|
103
|
+
return
|
|
104
|
+
|
|
105
|
+
package_name = 'materials-commons-cli'
|
|
106
|
+
try:
|
|
107
|
+
current_version = pkg_resources.get_distribution(package_name).version
|
|
108
|
+
response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
|
|
109
|
+
latest_version = response.json()["info"]["version"]
|
|
110
|
+
|
|
111
|
+
if current_version != latest_version:
|
|
112
|
+
print(
|
|
113
|
+
f"\nWarning: You are using an older version of the Materials Commons CLI ({current_version}).\n"
|
|
114
|
+
f"A newer version is available ({latest_version}).\n"
|
|
115
|
+
f"It is recommended you upgrade to the newest version: pip install --upgrade {package_name}\n",
|
|
116
|
+
file=sys.stderr,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
update_version_cache()
|
|
120
|
+
|
|
121
|
+
except Exception as e:
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def main(argv=None, working_dir=None):
|
|
126
|
+
if argv is None:
|
|
127
|
+
argv = sys.argv
|
|
128
|
+
if working_dir is None:
|
|
129
|
+
working_dir = os.getcwd()
|
|
130
|
+
try:
|
|
131
|
+
|
|
132
|
+
config = Config()
|
|
133
|
+
if config.REST_logging:
|
|
134
|
+
mcapi.Client.set_debug_on()
|
|
135
|
+
pass
|
|
136
|
+
|
|
137
|
+
parser = make_parser()
|
|
138
|
+
|
|
139
|
+
if len(argv) < 2:
|
|
140
|
+
parser.print_help()
|
|
141
|
+
return 1
|
|
142
|
+
|
|
143
|
+
# parse_args defaults to [1:] for args, but you need to
|
|
144
|
+
# exclude the rest of the args too, or validation will fail
|
|
145
|
+
args = parser.parse_args(argv[1:2])
|
|
146
|
+
|
|
147
|
+
if args.command in standard_interfaces:
|
|
148
|
+
result = standard_interfaces[args.command]['subcommand'](argv[2:], working_dir)
|
|
149
|
+
check_package_version()
|
|
150
|
+
return result
|
|
151
|
+
|
|
152
|
+
else:
|
|
153
|
+
print('Unrecognized command')
|
|
154
|
+
parser.print_help()
|
|
155
|
+
return 1
|
|
156
|
+
|
|
157
|
+
except MissingRemoteException as e:
|
|
158
|
+
print("Error:", e)
|
|
159
|
+
clifuncs.print_remote_help()
|
|
160
|
+
return 1
|
|
161
|
+
|
|
162
|
+
except MultipleRemoteException as e:
|
|
163
|
+
print("Error:", e)
|
|
164
|
+
print(
|
|
165
|
+
'** Please edit .mc/config.json to include `"remote":{"mcurl": "Materials Commons https address here","email": "YOUR_EMAIL_HERE"}` **')
|
|
166
|
+
return 1
|
|
167
|
+
|
|
168
|
+
except NoDefaultRemoteException as e:
|
|
169
|
+
print("Error:", e)
|
|
170
|
+
print("Set the default remote with:")
|
|
171
|
+
print(" mc remote --set-default EMAIL URL")
|
|
172
|
+
clifuncs.print_remote_help()
|
|
173
|
+
return 1
|
|
174
|
+
|
|
175
|
+
except MCCLIException as e:
|
|
176
|
+
print("CLI Error:", e)
|
|
177
|
+
return 1
|
|
178
|
+
|
|
179
|
+
except mcapi.MCAPIError as e:
|
|
180
|
+
import json
|
|
181
|
+
print("API Error:", e)
|
|
182
|
+
print("Writing error message to 'mcapi_error.json'")
|
|
183
|
+
with open('mcapi_error.json', 'w') as f:
|
|
184
|
+
json.dump(e.response.json(), f, indent=2)
|
|
185
|
+
return 1
|
|
@@ -21,8 +21,9 @@ def make_parser():
|
|
|
21
21
|
|
|
22
22
|
parser.add_argument('-l', '--list', action="store_true", default=False, help='List known remote urls.')
|
|
23
23
|
parser.add_argument('--show-apikey', action="store_true", default=False, help='Show apikey.')
|
|
24
|
-
parser.add_argument('--add', nargs=
|
|
25
|
-
parser.add_argument('--remove', nargs=
|
|
24
|
+
parser.add_argument('--add', nargs=1, metavar=('EMAIL'), help='Add a new remote. Defaults to URL https://materialscommons.org/api. Use --url to specify a different URL.')
|
|
25
|
+
parser.add_argument('--remove', nargs=1, metavar=('EMAIL'), help='Remove a remote from the list. Defaults to URL https://materialscommons.org/api. Use --url to specify a different URL.')
|
|
26
|
+
parser.add_argument('--url', default='https://materialscommons.org/api', help='Remote server API URL (default: https://materialscommons.org/api)')
|
|
26
27
|
parser.add_argument('--set-default', nargs=2, metavar=('EMAIL', 'URL'), help='Set default remote to be used when not in a project.')
|
|
27
28
|
return parser
|
|
28
29
|
|
|
@@ -46,7 +47,7 @@ def remote_subcommand(argv, working_dir):
|
|
|
46
47
|
|
|
47
48
|
elif args.add:
|
|
48
49
|
email = args.add[0]
|
|
49
|
-
url = args.
|
|
50
|
+
url = args.url
|
|
50
51
|
|
|
51
52
|
config = Config()
|
|
52
53
|
remote_config = RemoteConfig(mcurl=url, email=email)
|
|
@@ -71,12 +72,14 @@ def remote_subcommand(argv, working_dir):
|
|
|
71
72
|
|
|
72
73
|
config.remotes.append(remote_config)
|
|
73
74
|
config.save()
|
|
75
|
+
if url == 'https://materialscommons.org/api':
|
|
76
|
+
set_default_remote(email, url)
|
|
74
77
|
print("Added " + email + " at " + url)
|
|
75
78
|
|
|
76
79
|
|
|
77
80
|
elif args.remove:
|
|
78
81
|
email = args.remove[0]
|
|
79
|
-
url = args.
|
|
82
|
+
url = args.url
|
|
80
83
|
|
|
81
84
|
config = Config()
|
|
82
85
|
remote_config = RemoteConfig(mcurl=url, email=email)
|
|
@@ -91,17 +94,9 @@ def remote_subcommand(argv, working_dir):
|
|
|
91
94
|
elif args.set_default:
|
|
92
95
|
email = args.set_default[0]
|
|
93
96
|
url = args.set_default[1]
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if remote_config in config.remotes:
|
|
99
|
-
config.default_remote = config.remotes[config.remotes.index(remote_config)]
|
|
100
|
-
else:
|
|
101
|
-
print("Failed: " + email + " at " + url + " not found.")
|
|
102
|
-
print_remotes(config.remotes)
|
|
103
|
-
return 1
|
|
104
|
-
config.save()
|
|
97
|
+
rv = set_default_remote(email, url)
|
|
98
|
+
if rv != 0:
|
|
99
|
+
return rv
|
|
105
100
|
print("Set default: " + email + " at " + url)
|
|
106
101
|
|
|
107
102
|
else:
|
|
@@ -117,3 +112,16 @@ def remote_subcommand(argv, working_dir):
|
|
|
117
112
|
return 1
|
|
118
113
|
|
|
119
114
|
return
|
|
115
|
+
|
|
116
|
+
def set_default_remote(email, url):
|
|
117
|
+
config = Config()
|
|
118
|
+
remote_config = RemoteConfig(mcurl=url, email=email)
|
|
119
|
+
|
|
120
|
+
if remote_config in config.remotes:
|
|
121
|
+
config.default_remote = config.remotes[config.remotes.index(remote_config)]
|
|
122
|
+
else:
|
|
123
|
+
print("Failed: " + email + " at " + url + " not found.")
|
|
124
|
+
print_remotes(config.remotes)
|
|
125
|
+
return 1
|
|
126
|
+
config.save()
|
|
127
|
+
return 0
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/up.py
RENAMED
|
@@ -29,8 +29,8 @@ def make_parser():
|
|
|
29
29
|
parser.add_argument('paths', nargs='*', default=None, help='Files or directories')
|
|
30
30
|
parser.add_argument('-r', '--recursive', action="store_true", default=False,
|
|
31
31
|
help='Upload directory contents recursively')
|
|
32
|
-
parser.add_argument('--limit', nargs=1, type=float, default=[
|
|
33
|
-
help='File size upload limit (MB). Default=
|
|
32
|
+
parser.add_argument('--limit', nargs=1, type=float, default=[250],
|
|
33
|
+
help='File size upload limit (MB). Default=250MB. Does not apply to Globus uploads.')
|
|
34
34
|
parser.add_argument('-g', '--globus', action="store_true", default=False,
|
|
35
35
|
help=globus_help)
|
|
36
36
|
parser.add_argument('--label', nargs=1, type=str,
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons_cli.egg-info/PKG-INFO
RENAMED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: materials-commons-cli
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.2
|
|
4
4
|
Summary: Materials Commons CLI
|
|
5
5
|
Home-page: https://materials-commons.github.io/materials-commons-cli/html/index.html
|
|
6
6
|
Author: Materials Commons development team
|
|
7
|
-
Author-email: materials-commons-
|
|
7
|
+
Author-email: materials-commons-help@umich.edu
|
|
8
8
|
License: MIT
|
|
9
9
|
Keywords: materials science mc materials-commons prisms
|
|
10
|
+
Platform: UNKNOWN
|
|
10
11
|
Classifier: Development Status :: 4 - Beta
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -21,3 +22,4 @@ This package contains the materials_commons.cli module. This module is an interf
|
|
|
21
22
|
Commons web site, https://materialscommons.org/, or a similar site based on the
|
|
22
23
|
Materials Commons code (https://github.com/materials-commons/materialscommons), and intend to use these
|
|
23
24
|
tools in that context.
|
|
25
|
+
|
|
@@ -14,7 +14,7 @@ setup(
|
|
|
14
14
|
tools in that context.""",
|
|
15
15
|
url='https://materials-commons.github.io/materials-commons-cli/html/index.html',
|
|
16
16
|
author='Materials Commons development team',
|
|
17
|
-
author_email='materials-commons-
|
|
17
|
+
author_email='materials-commons-help@umich.edu',
|
|
18
18
|
license='MIT',
|
|
19
19
|
package_data={
|
|
20
20
|
# If any package contains *.txt or *.rst files, include them:
|
|
@@ -56,6 +56,7 @@ setup(
|
|
|
56
56
|
"python-dateutil",
|
|
57
57
|
"pyyaml",
|
|
58
58
|
"requests",
|
|
59
|
+
"setuptools",
|
|
59
60
|
"sortedcontainers",
|
|
60
61
|
"tabulate"
|
|
61
62
|
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.1.1'
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import os
|
|
3
|
-
import sys
|
|
4
|
-
from io import StringIO
|
|
5
|
-
|
|
6
|
-
import materials_commons.api as mcapi
|
|
7
|
-
|
|
8
|
-
from materials_commons.cli.subcommands.clone import clone_subcommand
|
|
9
|
-
from materials_commons.cli.subcommands.config import config_subcommand
|
|
10
|
-
from materials_commons.cli.subcommands.dataset import DatasetSubcommand
|
|
11
|
-
from materials_commons.cli.subcommands.down import down_subcommand
|
|
12
|
-
from materials_commons.cli.subcommands.expt import ExptSubcommand
|
|
13
|
-
from materials_commons.cli.subcommands.fetch import fetch_subcommand
|
|
14
|
-
from materials_commons.cli.subcommands.init import init_subcommand
|
|
15
|
-
from materials_commons.cli.subcommands.ls import ls_subcommand
|
|
16
|
-
from materials_commons.cli.subcommands.mkdir import mkdir_subcommand
|
|
17
|
-
from materials_commons.cli.subcommands.mv import mv_subcommand
|
|
18
|
-
# from materials_commons.cli.subcommands.proc import ProcSubcommand
|
|
19
|
-
from materials_commons.cli.subcommands.proj import ProjSubcommand
|
|
20
|
-
from materials_commons.cli.subcommands.remote import remote_subcommand
|
|
21
|
-
from materials_commons.cli.subcommands.rm import rm_subcommand
|
|
22
|
-
# from materials_commons.cli.subcommands.samp import SampSubcommand
|
|
23
|
-
from materials_commons.cli.subcommands.globus import globus_subcommand
|
|
24
|
-
from materials_commons.cli.subcommands.up import up_subcommand
|
|
25
|
-
from materials_commons.cli.subcommands.versions import versions_subcommand
|
|
26
|
-
|
|
27
|
-
import materials_commons.cli.functions as clifuncs
|
|
28
|
-
from materials_commons.cli.user_config import Config
|
|
29
|
-
from materials_commons.cli.exceptions import MCCLIException, MissingRemoteException, \
|
|
30
|
-
MultipleRemoteException, NoDefaultRemoteException
|
|
31
|
-
|
|
32
|
-
standard_usage = [
|
|
33
|
-
{'name': 'remote', 'desc': 'List servers', 'subcommand': remote_subcommand},
|
|
34
|
-
{'name': 'proj', 'desc': 'List projects', 'subcommand': ProjSubcommand()},
|
|
35
|
-
{'name': 'dataset', 'desc': 'List datasets', 'subcommand': DatasetSubcommand()},
|
|
36
|
-
{'name': 'expt', 'desc': 'List experiments', 'subcommand': ExptSubcommand()},
|
|
37
|
-
{'name': 'init', 'desc': 'Initialize a new project', 'subcommand': init_subcommand},
|
|
38
|
-
{'name': 'clone', 'desc': 'Clone an existing project', 'subcommand': clone_subcommand},
|
|
39
|
-
{'name': 'ls', 'desc': 'List directory contents', 'subcommand': ls_subcommand},
|
|
40
|
-
{'name': 'mkdir', 'desc': 'Make directories', 'subcommand': mkdir_subcommand},
|
|
41
|
-
{'name': 'rm', 'desc': 'Remove files and directories', 'subcommand': rm_subcommand},
|
|
42
|
-
{'name': 'mv', 'desc': 'Move files', 'subcommand': mv_subcommand},
|
|
43
|
-
{'name': 'fetch', 'desc': 'Remote data fetching and configuration', 'subcommand': fetch_subcommand},
|
|
44
|
-
{'name': 'up', 'desc': 'Upload files', 'subcommand': up_subcommand},
|
|
45
|
-
{'name': 'down', 'desc': 'Download files', 'subcommand': down_subcommand},
|
|
46
|
-
{'name': 'globus', 'desc': 'Manage Globus uploads and downloads', 'subcommand': globus_subcommand},
|
|
47
|
-
{'name': 'versions', 'desc': 'List file versions', 'subcommand': versions_subcommand},
|
|
48
|
-
# {'name': 'proc', 'desc': 'List processes', 'subcommand': ProcSubcommand()},
|
|
49
|
-
# {'name': 'samp', 'desc': 'List samples', 'subcommand': SampSubcommand()},
|
|
50
|
-
{'name': 'config', 'desc': 'Configure `mc`', 'subcommand': config_subcommand}
|
|
51
|
-
]
|
|
52
|
-
standard_interfaces = {d['name']: d for d in standard_usage}
|
|
53
|
-
|
|
54
|
-
def make_parser():
|
|
55
|
-
|
|
56
|
-
usage_help = StringIO()
|
|
57
|
-
usage_help.write("mc <command> [<args>]\n\n")
|
|
58
|
-
usage_help.write("The standard mc commands are:\n")
|
|
59
|
-
|
|
60
|
-
for name, interface in standard_interfaces.items():
|
|
61
|
-
usage_help.write(" {:10} {:40}\n".format(name, interface['desc']))
|
|
62
|
-
|
|
63
|
-
parser = argparse.ArgumentParser(
|
|
64
|
-
description='Materials Commons command line interface',
|
|
65
|
-
usage=usage_help.getvalue())
|
|
66
|
-
parser.add_argument('command', help='Subcommand to run')
|
|
67
|
-
|
|
68
|
-
return parser
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def main(argv=None, working_dir=None):
|
|
72
|
-
if argv is None:
|
|
73
|
-
argv = sys.argv
|
|
74
|
-
if working_dir is None:
|
|
75
|
-
working_dir = os.getcwd()
|
|
76
|
-
try:
|
|
77
|
-
|
|
78
|
-
config = Config()
|
|
79
|
-
if config.REST_logging:
|
|
80
|
-
mcapi.Client.set_debug_on()
|
|
81
|
-
pass
|
|
82
|
-
|
|
83
|
-
parser = make_parser()
|
|
84
|
-
|
|
85
|
-
if len(argv) < 2:
|
|
86
|
-
parser.print_help()
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
# parse_args defaults to [1:] for args, but you need to
|
|
90
|
-
# exclude the rest of the args too, or validation will fail
|
|
91
|
-
args = parser.parse_args(argv[1:2])
|
|
92
|
-
|
|
93
|
-
if args.command in standard_interfaces:
|
|
94
|
-
result = standard_interfaces[args.command]['subcommand'](argv[2:], working_dir)
|
|
95
|
-
return result
|
|
96
|
-
|
|
97
|
-
else:
|
|
98
|
-
print('Unrecognized command')
|
|
99
|
-
parser.print_help()
|
|
100
|
-
return 1
|
|
101
|
-
|
|
102
|
-
except MissingRemoteException as e:
|
|
103
|
-
print("Error:", e)
|
|
104
|
-
clifuncs.print_remote_help()
|
|
105
|
-
return 1
|
|
106
|
-
|
|
107
|
-
except MultipleRemoteException as e:
|
|
108
|
-
print("Error:", e)
|
|
109
|
-
print('** Please edit .mc/config.json to include `"remote":{"mcurl": "' + data['remote_url']
|
|
110
|
-
+ '", "email": "YOUR_EMAIL_HERE"}` **')
|
|
111
|
-
return 1
|
|
112
|
-
|
|
113
|
-
except NoDefaultRemoteException as e:
|
|
114
|
-
print("Error:", e)
|
|
115
|
-
print("Set the default remote with:")
|
|
116
|
-
print(" mc remote --set-default EMAIL URL")
|
|
117
|
-
clifuncs.print_remote_help()
|
|
118
|
-
return 1
|
|
119
|
-
|
|
120
|
-
except MCCLIException as e:
|
|
121
|
-
print("CLI Error:", e)
|
|
122
|
-
return 1
|
|
123
|
-
|
|
124
|
-
except mcapi.MCAPIError as e:
|
|
125
|
-
import json
|
|
126
|
-
print("API Error:", e)
|
|
127
|
-
print("Writing error message to 'mcapi_error.json'")
|
|
128
|
-
with open('mcapi_error.json', 'w') as f:
|
|
129
|
-
json.dump(e.response.json(), f, indent=2)
|
|
130
|
-
return 1
|
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/LICENSE.txt
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/cloned_project.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/exceptions.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/file_functions.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/list_objects.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/print_formatter.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/sqltable.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/ls.py
RENAMED
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/mv.py
RENAMED
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/subcommands/rm.py
RENAMED
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/tmp_functions.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/tree_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/materials_commons/cli/user_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_treecompare_no_cache.py
RENAMED
|
File without changes
|
{materials_commons-cli-2.1.1 → materials_commons-cli-2.1.2}/test/test_treecompare_with_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|