Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-os
neo.py@77:46124d75dae7, 2016-03-30 (annotated)
- Committer:
- Christopher Haster
- Date:
- Wed Mar 30 21:48:23 2016 -0500
- Revision:
- 77:46124d75dae7
- Parent:
- 76:8c6feef9d15a
- Parent:
- 75:081959a31b02
- Child:
- 79:7be8ab60beec
Merged
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Christopher Haster |
15:a6b1f4e65bf4 | 1 | #!/usr/bin/env python |
| Christopher Haster |
15:a6b1f4e65bf4 | 2 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 3 | import argparse |
| Christopher Haster |
15:a6b1f4e65bf4 | 4 | import sys |
| Christopher Haster |
15:a6b1f4e65bf4 | 5 | import re |
| Christopher Haster |
15:a6b1f4e65bf4 | 6 | import subprocess |
| Christopher Haster |
15:a6b1f4e65bf4 | 7 | import os |
| Christopher Haster |
15:a6b1f4e65bf4 | 8 | import contextlib |
| Christopher Haster |
15:a6b1f4e65bf4 | 9 | import shutil |
| Christopher Haster |
35:ffcfa5ace437 | 10 | from collections import * |
| Christopher Haster |
15:a6b1f4e65bf4 | 11 | from itertools import * |
| Christopher Haster |
15:a6b1f4e65bf4 | 12 | |
| screamer | 47:386f8c519142 | 13 | # Default paths to Mercurial and Git |
| Christopher Haster |
50:3770a8991c11 | 14 | hg_cmd = 'hg' |
| Christopher Haster |
50:3770a8991c11 | 15 | git_cmd = 'git' |
| screamer | 47:386f8c519142 | 16 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 17 | # Subparser handling |
| Christopher Haster |
15:a6b1f4e65bf4 | 18 | parser = argparse.ArgumentParser() |
| Christopher Haster |
15:a6b1f4e65bf4 | 19 | subparsers = parser.add_subparsers() |
| Christopher Haster |
15:a6b1f4e65bf4 | 20 | |
| screamer | 70:e6f7587c6562 | 21 | def message(msg): |
| screamer | 70:e6f7587c6562 | 22 | return "["+os.path.basename(sys.argv[0])+"] "+msg+"\n" |
| screamer | 70:e6f7587c6562 | 23 | |
| screamer | 63:3b00ba456e00 | 24 | def log(msg): |
| screamer | 70:e6f7587c6562 | 25 | sys.stderr.write(message(msg)) |
| screamer | 70:e6f7587c6562 | 26 | |
| screamer | 70:e6f7587c6562 | 27 | def action(msg): |
| screamer | 70:e6f7587c6562 | 28 | sys.stderr.write("---\n"+message(msg)) |
| screamer | 63:3b00ba456e00 | 29 | |
| screamer | 63:3b00ba456e00 | 30 | def error(msg, code): |
| screamer | 70:e6f7587c6562 | 31 | sys.stderr.write("---\n["+os.path.basename(sys.argv[0])+" ERROR] "+msg+"\n---\n") |
| screamer | 63:3b00ba456e00 | 32 | sys.exit(code) |
| screamer | 70:e6f7587c6562 | 33 | |
| screamer | 70:e6f7587c6562 | 34 | def repo_or_die(): |
| screamer | 70:e6f7587c6562 | 35 | repo = Repo.fromrepo() |
| screamer | 70:e6f7587c6562 | 36 | if repo.scm is None: |
| screamer | 70:e6f7587c6562 | 37 | error("Current folder is not a repository", -1) |
| screamer | 70:e6f7587c6562 | 38 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 39 | def subcommand(name, *args, **kwargs): |
| Christopher Haster |
15:a6b1f4e65bf4 | 40 | def subcommand(command): |
| Christopher Haster |
15:a6b1f4e65bf4 | 41 | subparser = subparsers.add_parser(name, **kwargs) |
| Christopher Haster |
15:a6b1f4e65bf4 | 42 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 43 | for arg in args: |
| Christopher Haster |
15:a6b1f4e65bf4 | 44 | if arg.endswith('?'): |
| Christopher Haster |
15:a6b1f4e65bf4 | 45 | subparser.add_argument(arg.strip('?'), nargs='?') |
| Christopher Haster |
15:a6b1f4e65bf4 | 46 | elif arg.endswith('*'): |
| Christopher Haster |
15:a6b1f4e65bf4 | 47 | pass |
| Christopher Haster |
15:a6b1f4e65bf4 | 48 | else: |
| Christopher Haster |
15:a6b1f4e65bf4 | 49 | subparser.add_argument(arg) |
| Christopher Haster |
15:a6b1f4e65bf4 | 50 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 51 | def thunk(parsed_args): |
| Christopher Haster |
15:a6b1f4e65bf4 | 52 | ordered_args = [vars(parsed_args)[arg.strip('?*')] |
| Christopher Haster |
15:a6b1f4e65bf4 | 53 | if not arg.endswith('*') else remainder |
| Christopher Haster |
15:a6b1f4e65bf4 | 54 | for arg in args] |
| Christopher Haster |
15:a6b1f4e65bf4 | 55 | return command(*ordered_args) |
| Christopher Haster |
15:a6b1f4e65bf4 | 56 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 57 | subparser.set_defaults(command=thunk) |
| Christopher Haster |
15:a6b1f4e65bf4 | 58 | return command |
| Christopher Haster |
15:a6b1f4e65bf4 | 59 | return subcommand |
| Christopher Haster |
15:a6b1f4e65bf4 | 60 | |
| Christopher Haster |
72:08d69d476038 | 61 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 62 | # Process execution |
| Christopher Haster |
15:a6b1f4e65bf4 | 63 | class ProcessException(Exception): |
| Christopher Haster |
15:a6b1f4e65bf4 | 64 | pass |
| Christopher Haster |
15:a6b1f4e65bf4 | 65 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 66 | def popen(command, stdin=None, **kwargs): |
| Christopher Haster |
15:a6b1f4e65bf4 | 67 | # print for debugging |
| screamer | 71:ddc08f2d5697 | 68 | log("Exec "+' '.join(command)) |
| Christopher Haster |
15:a6b1f4e65bf4 | 69 | proc = subprocess.Popen(command, **kwargs) |
| Christopher Haster |
15:a6b1f4e65bf4 | 70 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 71 | if proc.wait() != 0: |
| Christopher Haster |
15:a6b1f4e65bf4 | 72 | raise ProcessException(proc.returncode) |
| Christopher Haster |
15:a6b1f4e65bf4 | 73 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 74 | def pquery(command, stdin=None, **kwargs): |
| Christopher Haster |
15:a6b1f4e65bf4 | 75 | proc = subprocess.Popen(command, stdout=subprocess.PIPE, **kwargs) |
| Christopher Haster |
15:a6b1f4e65bf4 | 76 | stdout, _ = proc.communicate(stdin) |
| Christopher Haster |
15:a6b1f4e65bf4 | 77 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 78 | if proc.returncode != 0: |
| Christopher Haster |
15:a6b1f4e65bf4 | 79 | raise ProcessException(proc.returncode) |
| Christopher Haster |
15:a6b1f4e65bf4 | 80 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 81 | return stdout |
| Christopher Haster |
15:a6b1f4e65bf4 | 82 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 83 | # Directory navigation |
| Christopher Haster |
15:a6b1f4e65bf4 | 84 | @contextlib.contextmanager |
| Christopher Haster |
15:a6b1f4e65bf4 | 85 | def cd(newdir): |
| Christopher Haster |
15:a6b1f4e65bf4 | 86 | prevdir = os.getcwd() |
| Christopher Haster |
15:a6b1f4e65bf4 | 87 | os.chdir(newdir) |
| Christopher Haster |
15:a6b1f4e65bf4 | 88 | try: |
| Christopher Haster |
15:a6b1f4e65bf4 | 89 | yield |
| Christopher Haster |
15:a6b1f4e65bf4 | 90 | finally: |
| Christopher Haster |
15:a6b1f4e65bf4 | 91 | os.chdir(prevdir) |
| Christopher Haster |
15:a6b1f4e65bf4 | 92 | |
| Christopher Haster |
72:08d69d476038 | 93 | def relpath(root, path): |
| Christopher Haster |
72:08d69d476038 | 94 | return path[len(root)+1:] |
| Christopher Haster |
72:08d69d476038 | 95 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 96 | # Handling for multiple version controls |
| Christopher Haster |
35:ffcfa5ace437 | 97 | scms = OrderedDict() |
| Christopher Haster |
35:ffcfa5ace437 | 98 | def scm(name): |
| Christopher Haster |
35:ffcfa5ace437 | 99 | def scm(cls): |
| Christopher Haster |
35:ffcfa5ace437 | 100 | scms[name] = cls() |
| Christopher Haster |
35:ffcfa5ace437 | 101 | return cls |
| Christopher Haster |
35:ffcfa5ace437 | 102 | return scm |
| Christopher Haster |
35:ffcfa5ace437 | 103 | |
| Christopher Haster |
35:ffcfa5ace437 | 104 | def staticclass(cls): |
| Christopher Haster |
35:ffcfa5ace437 | 105 | for k, v in cls.__dict__.items(): |
| Christopher Haster |
36:5f4546dde73b | 106 | if hasattr(v, '__call__') and not k.startswith('__'): |
| Christopher Haster |
35:ffcfa5ace437 | 107 | setattr(cls, k, staticmethod(v)) |
| Christopher Haster |
35:ffcfa5ace437 | 108 | |
| Christopher Haster |
35:ffcfa5ace437 | 109 | return cls |
| Christopher Haster |
35:ffcfa5ace437 | 110 | |
| Christopher Haster |
35:ffcfa5ace437 | 111 | @scm('hg') |
| Christopher Haster |
35:ffcfa5ace437 | 112 | @staticclass |
| Christopher Haster |
35:ffcfa5ace437 | 113 | class Hg(object): |
| Christopher Haster |
64:012dffea11fd | 114 | name = 'hg' |
| Christopher Haster |
64:012dffea11fd | 115 | |
| Christopher Haster |
35:ffcfa5ace437 | 116 | def clone(url, name=None, hash=None): |
| screamer | 70:e6f7587c6562 | 117 | action("Cloning "+name+" from "+url) |
| screamer | 47:386f8c519142 | 118 | popen([hg_cmd, 'clone', url, name] + (['-u', hash] if hash else [])) |
| Christopher Haster |
35:ffcfa5ace437 | 119 | |
| screamer | 63:3b00ba456e00 | 120 | def add(file): |
| screamer | 70:e6f7587c6562 | 121 | action("Adding "+file) |
| screamer | 63:3b00ba456e00 | 122 | popen([hg_cmd, 'add', file]) |
| screamer | 63:3b00ba456e00 | 123 | |
| Christopher Haster |
35:ffcfa5ace437 | 124 | def remove(file): |
| screamer | 70:e6f7587c6562 | 125 | action("Removing "+file) |
| screamer | 47:386f8c519142 | 126 | popen([hg_cmd, 'rm', '-f', file]) |
| Christopher Haster |
35:ffcfa5ace437 | 127 | try: |
| Christopher Haster |
35:ffcfa5ace437 | 128 | os.remove(file) |
| Christopher Haster |
35:ffcfa5ace437 | 129 | except OSError: |
| Christopher Haster |
35:ffcfa5ace437 | 130 | pass |
| Christopher Haster |
35:ffcfa5ace437 | 131 | |
| screamer | 63:3b00ba456e00 | 132 | def commit(): |
| screamer | 63:3b00ba456e00 | 133 | popen([hg_cmd, 'commit']) |
| screamer | 63:3b00ba456e00 | 134 | |
| screamer | 63:3b00ba456e00 | 135 | def push(): |
| screamer | 70:e6f7587c6562 | 136 | action("Pushing to remote repository") |
| screamer | 63:3b00ba456e00 | 137 | popen([hg_cmd, 'push']) |
| screamer | 63:3b00ba456e00 | 138 | |
| Christopher Haster |
35:ffcfa5ace437 | 139 | def pull(hash=None): |
| screamer | 70:e6f7587c6562 | 140 | action("Pulling from remote repository") |
| screamer | 47:386f8c519142 | 141 | popen([hg_cmd, 'pull']) |
| screamer | 47:386f8c519142 | 142 | popen([hg_cmd, 'update'] + (['-r', hash] if hash else [])) |
| Christopher Haster |
35:ffcfa5ace437 | 143 | |
| Christopher Haster |
68:14cc5a81333d | 144 | def status(): |
| Christopher Haster |
68:14cc5a81333d | 145 | popen([hg_cmd, 'status']) |
| Christopher Haster |
68:14cc5a81333d | 146 | |
| screamer | 63:3b00ba456e00 | 147 | def hash(): |
| screamer | 63:3b00ba456e00 | 148 | return pquery([hg_cmd, 'id', '-i']).strip().strip('+') |
| Christopher Haster |
76:8c6feef9d15a | 149 | |
| screamer | 63:3b00ba456e00 | 150 | def dirty(): |
| screamer | 63:3b00ba456e00 | 151 | return pquery([hg_cmd, 'status', '-q']) |
| Christopher Haster |
35:ffcfa5ace437 | 152 | |
| Christopher Haster |
76:8c6feef9d15a | 153 | def hook(): |
| Christopher Haster |
76:8c6feef9d15a | 154 | pass |
| Christopher Haster |
76:8c6feef9d15a | 155 | |
| Christopher Haster |
44:5ff277e7f754 | 156 | def ignore(file): |
| Christopher Haster |
52:25da1dfebd7a | 157 | hooked = False |
| Christopher Haster |
52:25da1dfebd7a | 158 | hook = 'ignore.local = .hg/hgignore' |
| Christopher Haster |
52:25da1dfebd7a | 159 | with open('.hg/hgrc') as f: |
| Christopher Haster |
52:25da1dfebd7a | 160 | if hook not in f.read().splitlines(): |
| Christopher Haster |
52:25da1dfebd7a | 161 | with open('.hg/hgrc', 'a') as f: |
| Christopher Haster |
52:25da1dfebd7a | 162 | f.write('[ui]\n') |
| Christopher Haster |
52:25da1dfebd7a | 163 | f.write(hook + '\n') |
| Christopher Haster |
52:25da1dfebd7a | 164 | |
| Christopher Haster |
44:5ff277e7f754 | 165 | file = '^%s/' % file |
| screamer | 46:915be4b5a8f0 | 166 | exclude = '.hg/hgignore' |
| Christopher Haster |
76:8c6feef9d15a | 167 | try: |
| Christopher Haster |
76:8c6feef9d15a | 168 | with open(exclude) as f: |
| Christopher Haster |
76:8c6feef9d15a | 169 | exists = file in f.read().splitlines() |
| Christopher Haster |
76:8c6feef9d15a | 170 | except IOError: |
| Christopher Haster |
76:8c6feef9d15a | 171 | exists = False |
| Christopher Haster |
76:8c6feef9d15a | 172 | |
| Christopher Haster |
76:8c6feef9d15a | 173 | if not exists: |
| Christopher Haster |
76:8c6feef9d15a | 174 | with open(exclude, 'a') as f: |
| Christopher Haster |
76:8c6feef9d15a | 175 | f.write(file + '\n') |
| Christopher Haster |
42:58b35941ebd0 | 176 | |
| Christopher Haster |
44:5ff277e7f754 | 177 | def unignore(file): |
| Christopher Haster |
44:5ff277e7f754 | 178 | file = '^%s/' % file |
| screamer | 46:915be4b5a8f0 | 179 | exclude = '.hg/hgignore' |
| Christopher Haster |
76:8c6feef9d15a | 180 | try: |
| Christopher Haster |
76:8c6feef9d15a | 181 | with open(exclude) as f: |
| Christopher Haster |
76:8c6feef9d15a | 182 | lines = f.read().splitlines() |
| Christopher Haster |
76:8c6feef9d15a | 183 | except: |
| Christopher Haster |
76:8c6feef9d15a | 184 | lines = '' |
| Christopher Haster |
42:58b35941ebd0 | 185 | |
| Christopher Haster |
44:5ff277e7f754 | 186 | if file not in lines: |
| Christopher Haster |
42:58b35941ebd0 | 187 | return |
| Christopher Haster |
42:58b35941ebd0 | 188 | |
| Christopher Haster |
44:5ff277e7f754 | 189 | lines.remove(file) |
| Christopher Haster |
42:58b35941ebd0 | 190 | |
| Christopher Haster |
42:58b35941ebd0 | 191 | with open(exclude, 'w') as f: |
| Christopher Haster |
42:58b35941ebd0 | 192 | f.write('\n'.join(lines) + '\n') |
| Christopher Haster |
42:58b35941ebd0 | 193 | |
| Christopher Haster |
35:ffcfa5ace437 | 194 | @scm('git') |
| Christopher Haster |
35:ffcfa5ace437 | 195 | @staticclass |
| Christopher Haster |
35:ffcfa5ace437 | 196 | class Git(object): |
| Christopher Haster |
64:012dffea11fd | 197 | name = 'git' |
| Christopher Haster |
64:012dffea11fd | 198 | |
| Christopher Haster |
35:ffcfa5ace437 | 199 | def clone(url, name=None, hash=None): |
| screamer | 70:e6f7587c6562 | 200 | action("Cloning "+name+" from "+url) |
| screamer | 47:386f8c519142 | 201 | popen([git_cmd, 'clone', url, name]) |
| Christopher Haster |
35:ffcfa5ace437 | 202 | if hash: |
| Christopher Haster |
39:8d6f31570710 | 203 | with cd(name): |
| screamer | 47:386f8c519142 | 204 | popen([git_cmd, 'checkout', '-q', hash]) |
| Christopher Haster |
35:ffcfa5ace437 | 205 | |
| screamer | 63:3b00ba456e00 | 206 | def add(file): |
| screamer | 70:e6f7587c6562 | 207 | action("Adding "+file) |
| screamer | 63:3b00ba456e00 | 208 | popen([git_cmd, 'add', file]) |
| screamer | 63:3b00ba456e00 | 209 | |
| screamer | 63:3b00ba456e00 | 210 | def remove(file): |
| screamer | 70:e6f7587c6562 | 211 | action("Removing "+file) |
| screamer | 63:3b00ba456e00 | 212 | popen([git_cmd, 'rm', '-f', file]) |
| Christopher Haster |
39:8d6f31570710 | 213 | |
| screamer | 63:3b00ba456e00 | 214 | def commit(): |
| screamer | 63:3b00ba456e00 | 215 | popen([git_cmd, 'commit', '-a']) |
| screamer | 63:3b00ba456e00 | 216 | |
| screamer | 63:3b00ba456e00 | 217 | def push(): |
| screamer | 70:e6f7587c6562 | 218 | action("Pushing to remote repository") |
| screamer | 63:3b00ba456e00 | 219 | popen([git_cmd, 'push', '--all']) |
| screamer | 63:3b00ba456e00 | 220 | |
| Christopher Haster |
39:8d6f31570710 | 221 | def pull(hash=None): |
| screamer | 70:e6f7587c6562 | 222 | action("Pulling from remote repository") |
| screamer | 47:386f8c519142 | 223 | popen([git_cmd, 'fetch', 'origin']) |
| screamer | 47:386f8c519142 | 224 | popen([git_cmd, 'merge'] + ([hash] if hash else [])) |
| Christopher Haster |
35:ffcfa5ace437 | 225 | |
| Christopher Haster |
68:14cc5a81333d | 226 | def status(): |
| Christopher Haster |
68:14cc5a81333d | 227 | popen([git_cmd, 'status', '-s']) |
| Christopher Haster |
68:14cc5a81333d | 228 | |
| screamer | 63:3b00ba456e00 | 229 | def hash(): |
| screamer | 63:3b00ba456e00 | 230 | return pquery([git_cmd, 'rev-parse', '--short', 'HEAD']).strip() |
| screamer | 63:3b00ba456e00 | 231 | |
| screamer | 63:3b00ba456e00 | 232 | def dirty(): |
| screamer | 63:3b00ba456e00 | 233 | return pquery([git_cmd, 'diff', '--name-only', 'HEAD']) |
| Christopher Haster |
40:2446665dfdf8 | 234 | |
| Christopher Haster |
76:8c6feef9d15a | 235 | def hook(): |
| Christopher Haster |
76:8c6feef9d15a | 236 | pass |
| Christopher Haster |
76:8c6feef9d15a | 237 | |
| Christopher Haster |
44:5ff277e7f754 | 238 | def ignore(file): |
| Christopher Haster |
42:58b35941ebd0 | 239 | exclude = '.git/info/exclude' |
| Christopher Haster |
76:8c6feef9d15a | 240 | try: |
| Christopher Haster |
76:8c6feef9d15a | 241 | with open(exclude) as f: |
| Christopher Haster |
76:8c6feef9d15a | 242 | exists = file in f.read().splitlines() |
| Christopher Haster |
76:8c6feef9d15a | 243 | except IOError: |
| Christopher Haster |
76:8c6feef9d15a | 244 | exists = False |
| Christopher Haster |
76:8c6feef9d15a | 245 | |
| Christopher Haster |
76:8c6feef9d15a | 246 | if not exists: |
| Christopher Haster |
76:8c6feef9d15a | 247 | with open(exclude, 'a') as f: |
| Christopher Haster |
76:8c6feef9d15a | 248 | f.write(file + '\n') |
| Christopher Haster |
42:58b35941ebd0 | 249 | |
| Christopher Haster |
44:5ff277e7f754 | 250 | def unignore(file): |
| Christopher Haster |
42:58b35941ebd0 | 251 | exclude = '.git/info/exclude' |
| Christopher Haster |
76:8c6feef9d15a | 252 | try: |
| Christopher Haster |
76:8c6feef9d15a | 253 | with open(exclude) as f: |
| Christopher Haster |
76:8c6feef9d15a | 254 | lines = f.read().splitlines() |
| Christopher Haster |
76:8c6feef9d15a | 255 | except: |
| Christopher Haster |
76:8c6feef9d15a | 256 | lines = '' |
| Christopher Haster |
42:58b35941ebd0 | 257 | |
| Christopher Haster |
44:5ff277e7f754 | 258 | if file not in lines: |
| Christopher Haster |
42:58b35941ebd0 | 259 | return |
| Christopher Haster |
42:58b35941ebd0 | 260 | |
| Christopher Haster |
44:5ff277e7f754 | 261 | lines.remove(file) |
| Christopher Haster |
42:58b35941ebd0 | 262 | |
| Christopher Haster |
42:58b35941ebd0 | 263 | with open(exclude, 'w') as f: |
| Christopher Haster |
42:58b35941ebd0 | 264 | f.write('\n'.join(lines) + '\n') |
| Christopher Haster |
40:2446665dfdf8 | 265 | |
| Christopher Haster |
35:ffcfa5ace437 | 266 | |
| Christopher Haster |
35:ffcfa5ace437 | 267 | # Repository object |
| Christopher Haster |
15:a6b1f4e65bf4 | 268 | class Repo(object): |
| Christopher Haster |
36:5f4546dde73b | 269 | @classmethod |
| Christopher Haster |
36:5f4546dde73b | 270 | def fromurl(cls, url, path=None): |
| Christopher Haster |
36:5f4546dde73b | 271 | repo = cls() |
| Christopher Haster |
36:5f4546dde73b | 272 | |
| Christopher Haster |
54:3cb9f99bbaaa | 273 | m = re.match('^(.*/([\w+-]+)(?:\.\w+)?)/?(?:#(.*))?$', url.strip()) |
| Christopher Haster |
36:5f4546dde73b | 274 | repo.name = os.path.basename(path or m.group(2)) |
| Christopher Haster |
36:5f4546dde73b | 275 | repo.path = os.path.abspath( |
| Christopher Haster |
36:5f4546dde73b | 276 | path or os.path.join(os.getcwd(), repo.name)) |
| Christopher Haster |
36:5f4546dde73b | 277 | |
| Christopher Haster |
36:5f4546dde73b | 278 | repo.repo = m.group(1) |
| Christopher Haster |
36:5f4546dde73b | 279 | repo.hash = m.group(3) |
| Christopher Haster |
36:5f4546dde73b | 280 | return repo |
| Christopher Haster |
15:a6b1f4e65bf4 | 281 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 282 | @classmethod |
| Christopher Haster |
36:5f4546dde73b | 283 | def fromlib(cls, lib=None): |
| Christopher Haster |
36:5f4546dde73b | 284 | assert lib.endswith('.lib') |
| Christopher Haster |
36:5f4546dde73b | 285 | with open(lib) as f: |
| Christopher Haster |
36:5f4546dde73b | 286 | return cls.fromurl(f.read(), lib[:-4]) |
| Christopher Haster |
15:a6b1f4e65bf4 | 287 | |
| Christopher Haster |
36:5f4546dde73b | 288 | @classmethod |
| Christopher Haster |
36:5f4546dde73b | 289 | def fromrepo(cls, path=None): |
| Christopher Haster |
36:5f4546dde73b | 290 | repo = cls() |
| Christopher Haster |
36:5f4546dde73b | 291 | repo.path = os.path.abspath(path or os.getcwd()) |
| Christopher Haster |
36:5f4546dde73b | 292 | repo.name = os.path.basename(repo.path) |
| Christopher Haster |
15:a6b1f4e65bf4 | 293 | |
| Christopher Haster |
36:5f4546dde73b | 294 | repo.synch() |
| Christopher Haster |
15:a6b1f4e65bf4 | 295 | return repo |
| Christopher Haster |
15:a6b1f4e65bf4 | 296 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 297 | @property |
| Christopher Haster |
15:a6b1f4e65bf4 | 298 | def lib(self): |
| Christopher Haster |
15:a6b1f4e65bf4 | 299 | return self.path + '.lib' |
| Christopher Haster |
15:a6b1f4e65bf4 | 300 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 301 | @property |
| Christopher Haster |
15:a6b1f4e65bf4 | 302 | def url(self): |
| Christopher Haster |
15:a6b1f4e65bf4 | 303 | if self.repo: |
| screamer | 60:52dc8fcb07d8 | 304 | return self.repo + '/' + ('#'+self.hash if self.hash else '') |
| Christopher Haster |
15:a6b1f4e65bf4 | 305 | |
| Christopher Haster |
36:5f4546dde73b | 306 | def synch(self): |
| Christopher Haster |
15:a6b1f4e65bf4 | 307 | if os.path.isdir(self.path): |
| Christopher Haster |
39:8d6f31570710 | 308 | try: |
| Christopher Haster |
39:8d6f31570710 | 309 | self.scm = self.getscm() |
| Christopher Haster |
39:8d6f31570710 | 310 | self.hash = self.gethash() |
| Christopher Haster |
39:8d6f31570710 | 311 | self.libs = list(self.getlibs()) |
| Christopher Haster |
39:8d6f31570710 | 312 | except ProcessException: |
| Christopher Haster |
39:8d6f31570710 | 313 | pass |
| Christopher Haster |
15:a6b1f4e65bf4 | 314 | |
| Christopher Haster |
37:bf73ffd98cca | 315 | if os.path.isfile(self.lib): |
| Christopher Haster |
39:8d6f31570710 | 316 | try: |
| Christopher Haster |
39:8d6f31570710 | 317 | self.repo = self.getrepo() |
| Christopher Haster |
39:8d6f31570710 | 318 | except ProcessException: |
| Christopher Haster |
39:8d6f31570710 | 319 | pass |
| Christopher Haster |
37:bf73ffd98cca | 320 | |
| Christopher Haster |
35:ffcfa5ace437 | 321 | def getscm(self): |
| Christopher Haster |
36:5f4546dde73b | 322 | for name, scm in scms.items(): |
| Christopher Haster |
36:5f4546dde73b | 323 | if os.path.isdir(os.path.join(self.path, '.'+name)): |
| Christopher Haster |
36:5f4546dde73b | 324 | return scm |
| Christopher Haster |
35:ffcfa5ace437 | 325 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 326 | def gethash(self): |
| Christopher Haster |
66:bfe0df4ef9f5 | 327 | if self.scm: |
| Christopher Haster |
66:bfe0df4ef9f5 | 328 | with cd(self.path): |
| Christopher Haster |
66:bfe0df4ef9f5 | 329 | return self.scm.hash() |
| Christopher Haster |
15:a6b1f4e65bf4 | 330 | |
| Christopher Haster |
36:5f4546dde73b | 331 | def getlibs(self): |
| Christopher Haster |
36:5f4546dde73b | 332 | for root, dirs, files in os.walk(self.path): |
| Christopher Haster |
36:5f4546dde73b | 333 | dirs[:] = [d for d in dirs if not d.startswith('.')] |
| Christopher Haster |
36:5f4546dde73b | 334 | files[:] = [f for f in files if not f.startswith('.')] |
| Christopher Haster |
36:5f4546dde73b | 335 | |
| Christopher Haster |
36:5f4546dde73b | 336 | for file in files: |
| Christopher Haster |
36:5f4546dde73b | 337 | if file.endswith('.lib'): |
| Christopher Haster |
36:5f4546dde73b | 338 | yield Repo.fromlib(os.path.join(root, file)) |
| Christopher Haster |
49:977ea8d3e661 | 339 | if file[:-4] in dirs: |
| Christopher Haster |
49:977ea8d3e661 | 340 | dirs.remove(file[:-4]) |
| Christopher Haster |
36:5f4546dde73b | 341 | |
| Christopher Haster |
37:bf73ffd98cca | 342 | def getrepo(self): |
| Christopher Haster |
37:bf73ffd98cca | 343 | with open(self.lib) as f: |
| Christopher Haster |
37:bf73ffd98cca | 344 | return Repo.fromurl(f.read()).repo |
| Christopher Haster |
37:bf73ffd98cca | 345 | |
| Christopher Haster |
36:5f4546dde73b | 346 | def write(self): |
| Christopher Haster |
38:0ca5eea23af9 | 347 | if os.path.isfile(self.lib): |
| Christopher Haster |
38:0ca5eea23af9 | 348 | with open(self.lib) as f: |
| Christopher Haster |
38:0ca5eea23af9 | 349 | if f.read().strip() == self.url.strip(): |
| Christopher Haster |
44:5ff277e7f754 | 350 | print self.name, 'unmodified' |
| Christopher Haster |
38:0ca5eea23af9 | 351 | return |
| Christopher Haster |
36:5f4546dde73b | 352 | |
| Christopher Haster |
38:0ca5eea23af9 | 353 | with open(self.lib, 'w') as f: |
| Christopher Haster |
38:0ca5eea23af9 | 354 | f.write(self.url + '\n') |
| Christopher Haster |
36:5f4546dde73b | 355 | |
| Christopher Haster |
44:5ff277e7f754 | 356 | print self.name, '->', self.url |
| Christopher Haster |
44:5ff277e7f754 | 357 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 358 | # Clone command |
| Christopher Haster |
15:a6b1f4e65bf4 | 359 | @subcommand('import', 'url', 'name?', |
| screamer | 63:3b00ba456e00 | 360 | help='Import a program tree') |
| Christopher Haster |
36:5f4546dde73b | 361 | def import_(url, path=None): |
| Christopher Haster |
36:5f4546dde73b | 362 | repo = Repo.fromurl(url, path) |
| Christopher Haster |
15:a6b1f4e65bf4 | 363 | |
| Christopher Haster |
35:ffcfa5ace437 | 364 | for scm in scms.values(): |
| Christopher Haster |
15:a6b1f4e65bf4 | 365 | try: |
| Christopher Haster |
35:ffcfa5ace437 | 366 | scm.clone(repo.repo, repo.path, repo.hash) |
| Christopher Haster |
15:a6b1f4e65bf4 | 367 | break |
| Christopher Haster |
35:ffcfa5ace437 | 368 | except ProcessException: |
| Christopher Haster |
15:a6b1f4e65bf4 | 369 | pass |
| Christopher Haster |
15:a6b1f4e65bf4 | 370 | |
| Christopher Haster |
36:5f4546dde73b | 371 | repo.synch() |
| Christopher Haster |
15:a6b1f4e65bf4 | 372 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 373 | with cd(repo.path): |
| Christopher Haster |
76:8c6feef9d15a | 374 | deploy() |
| Christopher Haster |
19:6ace1080b8bb | 375 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 376 | # Deploy command |
| Christopher Haster |
15:a6b1f4e65bf4 | 377 | @subcommand('deploy', |
| screamer | 63:3b00ba456e00 | 378 | help='Import library in the current program or library') |
| Christopher Haster |
15:a6b1f4e65bf4 | 379 | def deploy(): |
| Christopher Haster |
36:5f4546dde73b | 380 | repo = Repo.fromrepo() |
| Christopher Haster |
36:5f4546dde73b | 381 | for lib in repo.libs: |
| Christopher Haster |
36:5f4546dde73b | 382 | import_(lib.url, lib.path) |
| Christopher Haster |
72:08d69d476038 | 383 | repo.scm.ignore(relpath(repo.path, lib.path)) |
| Christopher Haster |
15:a6b1f4e65bf4 | 384 | |
| Christopher Haster |
76:8c6feef9d15a | 385 | repo.scm.hook() |
| Christopher Haster |
76:8c6feef9d15a | 386 | |
| Christopher Haster |
76:8c6feef9d15a | 387 | if (not os.path.isfile('mbed_settings.py') and |
| Christopher Haster |
76:8c6feef9d15a | 388 | os.path.isfile('mbed-os/tools/default_settings.py')): |
| Christopher Haster |
76:8c6feef9d15a | 389 | shutil.copy('mbed-os/tools/default_settings.py', 'mbed_settings.py') |
| Christopher Haster |
76:8c6feef9d15a | 390 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 391 | # Install/uninstall command |
| Christopher Haster |
15:a6b1f4e65bf4 | 392 | @subcommand('add', 'url', 'name?', |
| screamer | 63:3b00ba456e00 | 393 | help='Add a library to the current program or library') |
| Christopher Haster |
36:5f4546dde73b | 394 | def add(url, path=None): |
| Christopher Haster |
36:5f4546dde73b | 395 | repo = Repo.fromrepo() |
| Christopher Haster |
15:a6b1f4e65bf4 | 396 | |
| Christopher Haster |
36:5f4546dde73b | 397 | lib = Repo.fromurl(url, path) |
| Christopher Haster |
36:5f4546dde73b | 398 | import_(lib.url, lib.path) |
| Christopher Haster |
72:08d69d476038 | 399 | repo.scm.ignore(relpath(repo.path, lib.path)) |
| Christopher Haster |
36:5f4546dde73b | 400 | lib.synch() |
| Christopher Haster |
15:a6b1f4e65bf4 | 401 | |
| Christopher Haster |
36:5f4546dde73b | 402 | lib.write() |
| Christopher Haster |
36:5f4546dde73b | 403 | repo.scm.add(lib.lib) |
| Christopher Haster |
15:a6b1f4e65bf4 | 404 | |
| Christopher Haster |
36:5f4546dde73b | 405 | @subcommand('remove', 'path', |
| screamer | 63:3b00ba456e00 | 406 | help='Remove a library from the current program or library') |
| Christopher Haster |
36:5f4546dde73b | 407 | def remove(path): |
| Christopher Haster |
36:5f4546dde73b | 408 | repo = Repo.fromrepo() |
| Christopher Haster |
36:5f4546dde73b | 409 | lib = Repo.fromrepo(path) |
| Christopher Haster |
15:a6b1f4e65bf4 | 410 | |
| Christopher Haster |
36:5f4546dde73b | 411 | repo.scm.remove(lib.lib) |
| Christopher Haster |
36:5f4546dde73b | 412 | shutil.rmtree(lib.path) |
| Christopher Haster |
72:08d69d476038 | 413 | repo.scm.unignore(relpath(repo.path, lib.path)) |
| Christopher Haster |
15:a6b1f4e65bf4 | 414 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 415 | # Publish command |
| Christopher Haster |
15:a6b1f4e65bf4 | 416 | @subcommand('publish', |
| screamer | 63:3b00ba456e00 | 417 | help='Publish working tree to remote repositories') |
| Christopher Haster |
18:1b4252106474 | 418 | def publish(always=True): |
| screamer | 67:c3b033f16424 | 419 | repo_or_die() |
| Christopher Haster |
36:5f4546dde73b | 420 | repo = Repo.fromrepo() |
| Christopher Haster |
36:5f4546dde73b | 421 | for lib in repo.libs: |
| Christopher Haster |
36:5f4546dde73b | 422 | with cd(lib.path): |
| Christopher Haster |
36:5f4546dde73b | 423 | publish(False) |
| Christopher Haster |
36:5f4546dde73b | 424 | synch() |
| Christopher Haster |
15:a6b1f4e65bf4 | 425 | |
| Christopher Haster |
36:5f4546dde73b | 426 | dirty = repo.scm.dirty() |
| Christopher Haster |
17:1e487c450f06 | 427 | |
| Christopher Haster |
36:5f4546dde73b | 428 | if dirty: |
| screamer | 70:e6f7587c6562 | 429 | action('Uncommitted changes in %s (%s)' % (repo.name, repo.path)) |
| screamer | 63:3b00ba456e00 | 430 | raw_input('Press enter to commit and push: ') |
| Christopher Haster |
36:5f4546dde73b | 431 | repo.scm.commit() |
| Christopher Haster |
17:1e487c450f06 | 432 | |
| Christopher Haster |
36:5f4546dde73b | 433 | if dirty or always: |
| Christopher Haster |
18:1b4252106474 | 434 | try: |
| Christopher Haster |
36:5f4546dde73b | 435 | repo.scm.push() |
| Christopher Haster |
18:1b4252106474 | 436 | except ProcessException as e: |
| Christopher Haster |
18:1b4252106474 | 437 | sys.exit(e[0]) |
| Christopher Haster |
15:a6b1f4e65bf4 | 438 | |
| Christopher Haster |
20:84d6e18cbc20 | 439 | # Update command |
| Christopher Haster |
20:84d6e18cbc20 | 440 | @subcommand('update', 'ref?', |
| screamer | 63:3b00ba456e00 | 441 | help='Update current program or library and recursively update all libraries') |
| Christopher Haster |
20:84d6e18cbc20 | 442 | def update(ref=None): |
| screamer | 67:c3b033f16424 | 443 | repo_or_die() |
| Christopher Haster |
36:5f4546dde73b | 444 | repo = Repo.fromrepo() |
| Christopher Haster |
36:5f4546dde73b | 445 | repo.scm.pull(ref) |
| Christopher Haster |
36:5f4546dde73b | 446 | |
| Christopher Haster |
36:5f4546dde73b | 447 | for lib in repo.libs: |
| Christopher Haster |
37:bf73ffd98cca | 448 | if (not os.path.isfile(lib.lib) or |
| Christopher Haster |
37:bf73ffd98cca | 449 | lib.repo != Repo.fromrepo(lib.path).repo): |
| Christopher Haster |
36:5f4546dde73b | 450 | with cd(lib.path): |
| Christopher Haster |
36:5f4546dde73b | 451 | if lib.cwd.dirty(): |
| screamer | 63:3b00ba456e00 | 452 | error('Uncommitted changes in %s (%s)\n' |
| screamer | 63:3b00ba456e00 | 453 | % (lib.name, lib.path), 1) |
| Christopher Haster |
20:84d6e18cbc20 | 454 | |
| Christopher Haster |
36:5f4546dde73b | 455 | shutil.rmtree(lib.path) |
| Christopher Haster |
72:08d69d476038 | 456 | repo.scm.unignore(relpath(repo.path, lib.path)) |
| Christopher Haster |
36:5f4546dde73b | 457 | |
| Christopher Haster |
36:5f4546dde73b | 458 | repo.synch() |
| Christopher Haster |
36:5f4546dde73b | 459 | |
| Christopher Haster |
36:5f4546dde73b | 460 | for lib in repo.libs: |
| Christopher Haster |
45:5a91306f7924 | 461 | if os.path.isdir(lib.path): |
| Christopher Haster |
45:5a91306f7924 | 462 | with cd(lib.path): |
| Christopher Haster |
45:5a91306f7924 | 463 | update(lib.hash) |
| Christopher Haster |
45:5a91306f7924 | 464 | else: |
| Christopher Haster |
42:58b35941ebd0 | 465 | import_(lib.url, lib.path) |
| Christopher Haster |
72:08d69d476038 | 466 | repo.scm.ignore(relpath(repo.path, lib.path)) |
| Christopher Haster |
20:84d6e18cbc20 | 467 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 468 | # Synch command |
| Christopher Haster |
15:a6b1f4e65bf4 | 469 | @subcommand('synch', |
| screamer | 63:3b00ba456e00 | 470 | help='Synchronize library references (.lib files)') |
| Christopher Haster |
15:a6b1f4e65bf4 | 471 | def synch(): |
| Christopher Haster |
36:5f4546dde73b | 472 | repo = Repo.fromrepo() |
| Christopher Haster |
36:5f4546dde73b | 473 | for lib in repo.libs: |
| Christopher Haster |
36:5f4546dde73b | 474 | lib.synch() |
| Christopher Haster |
43:8a4a902a0654 | 475 | lib.write() |
| Christopher Haster |
15:a6b1f4e65bf4 | 476 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 477 | # Compile command |
| Christopher Haster |
15:a6b1f4e65bf4 | 478 | @subcommand('compile', 'args*', |
| screamer | 63:3b00ba456e00 | 479 | help='Compile project using mbed OS build system') |
| Christopher Haster |
15:a6b1f4e65bf4 | 480 | def compile(args): |
| Christopher Haster |
15:a6b1f4e65bf4 | 481 | if not os.path.isdir('mbed-os'): |
| screamer | 63:3b00ba456e00 | 482 | error('mbed-os not found?\n', -1) |
| Christopher Haster |
15:a6b1f4e65bf4 | 483 | |
| Christopher Haster |
40:2446665dfdf8 | 484 | repo = Repo.fromrepo() |
| Christopher Haster |
40:2446665dfdf8 | 485 | |
| Christopher Haster |
21:1a3f920b6f07 | 486 | macros = [] |
| Christopher Haster |
15:a6b1f4e65bf4 | 487 | if os.path.isfile('MACROS.txt'): |
| Christopher Haster |
15:a6b1f4e65bf4 | 488 | with open('MACROS.txt') as f: |
| Christopher Haster |
15:a6b1f4e65bf4 | 489 | macros = f.read().splitlines() |
| Christopher Haster |
15:a6b1f4e65bf4 | 490 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 491 | env = os.environ.copy() |
| Christopher Haster |
15:a6b1f4e65bf4 | 492 | env['PYTHONPATH'] = '.' |
| Christopher Haster |
15:a6b1f4e65bf4 | 493 | popen(['python', 'mbed-os/tools/make.py'] |
| Christopher Haster |
15:a6b1f4e65bf4 | 494 | + list(chain.from_iterable(izip(repeat('-D'), macros))) |
| Christopher Haster |
36:5f4546dde73b | 495 | + ['--source=%s' % repo.path, |
| Christopher Haster |
36:5f4546dde73b | 496 | '--build=%s' % os.path.join(repo.path, '.build')] |
| Christopher Haster |
15:a6b1f4e65bf4 | 497 | + args, |
| Christopher Haster |
15:a6b1f4e65bf4 | 498 | env=env) |
| Christopher Haster |
15:a6b1f4e65bf4 | 499 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 500 | # Export command |
| Christopher Haster |
15:a6b1f4e65bf4 | 501 | @subcommand('export', 'args*', |
| screamer | 63:3b00ba456e00 | 502 | help='Generate project files for IDE') |
| Christopher Haster |
15:a6b1f4e65bf4 | 503 | def export(args): |
| Christopher Haster |
15:a6b1f4e65bf4 | 504 | if not os.path.isdir('mbed-os'): |
| screamer | 63:3b00ba456e00 | 505 | error('mbed-os not found?\n', -1) |
| Christopher Haster |
15:a6b1f4e65bf4 | 506 | |
| Christopher Haster |
40:2446665dfdf8 | 507 | repo = Repo.fromrepo() |
| Christopher Haster |
40:2446665dfdf8 | 508 | |
| Christopher Haster |
41:59e9d808ee05 | 509 | macros = [] |
| Christopher Haster |
41:59e9d808ee05 | 510 | if os.path.isfile('MACROS.txt'): |
| Christopher Haster |
41:59e9d808ee05 | 511 | with open('MACROS.txt') as f: |
| Christopher Haster |
41:59e9d808ee05 | 512 | macros = f.read().splitlines() |
| Christopher Haster |
41:59e9d808ee05 | 513 | |
| Christopher Haster |
18:1b4252106474 | 514 | env = os.environ.copy() |
| Christopher Haster |
18:1b4252106474 | 515 | env['PYTHONPATH'] = '.' |
| Christopher Haster |
15:a6b1f4e65bf4 | 516 | popen(['python', 'mbed-os/tools/project.py', |
| Christopher Haster |
36:5f4546dde73b | 517 | '--source=%s' % repo.path] |
| Christopher Haster |
41:59e9d808ee05 | 518 | + list(chain.from_iterable(izip(repeat('-D'), macros))) |
| Christopher Haster |
18:1b4252106474 | 519 | + args, |
| Christopher Haster |
18:1b4252106474 | 520 | env=env) |
| Christopher Haster |
15:a6b1f4e65bf4 | 521 | |
| Christopher Haster |
68:14cc5a81333d | 522 | # Helpful status commands |
| Christopher Haster |
65:905ba27af203 | 523 | @subcommand('ls', |
| Christopher Haster |
61:5c3f41de9d97 | 524 | help='list repositories recursively') |
| Christopher Haster |
61:5c3f41de9d97 | 525 | def list_(prefix=''): |
| Christopher Haster |
61:5c3f41de9d97 | 526 | repo = Repo.fromrepo() |
| Christopher Haster |
61:5c3f41de9d97 | 527 | print prefix + repo.name, '(%s)' % repo.hash |
| Christopher Haster |
61:5c3f41de9d97 | 528 | |
| Christopher Haster |
61:5c3f41de9d97 | 529 | for i, lib in enumerate(repo.libs): |
| Christopher Haster |
61:5c3f41de9d97 | 530 | if prefix: |
| Christopher Haster |
61:5c3f41de9d97 | 531 | nprefix = prefix[:-3] + ('| ' if prefix[-3] == '|' else ' ') |
| Christopher Haster |
61:5c3f41de9d97 | 532 | else: |
| Christopher Haster |
61:5c3f41de9d97 | 533 | nprefix = '' |
| Christopher Haster |
61:5c3f41de9d97 | 534 | |
| Christopher Haster |
61:5c3f41de9d97 | 535 | nprefix += '|- ' if i < len(repo.libs)-1 else '`- ' |
| Christopher Haster |
61:5c3f41de9d97 | 536 | |
| Christopher Haster |
61:5c3f41de9d97 | 537 | with cd(lib.path): |
| Christopher Haster |
61:5c3f41de9d97 | 538 | list_(nprefix) |
| Christopher Haster |
61:5c3f41de9d97 | 539 | |
| Christopher Haster |
68:14cc5a81333d | 540 | @subcommand('status', |
| Christopher Haster |
68:14cc5a81333d | 541 | help='show status of nested repositories') |
| Christopher Haster |
68:14cc5a81333d | 542 | def status(): |
| Christopher Haster |
68:14cc5a81333d | 543 | repo = Repo.fromrepo() |
| Christopher Haster |
68:14cc5a81333d | 544 | if repo.scm.dirty(): |
| Christopher Haster |
68:14cc5a81333d | 545 | print '---', repo.name, '---' |
| Christopher Haster |
68:14cc5a81333d | 546 | repo.scm.status() |
| Christopher Haster |
68:14cc5a81333d | 547 | |
| Christopher Haster |
68:14cc5a81333d | 548 | for lib in repo.libs: |
| Christopher Haster |
68:14cc5a81333d | 549 | with cd(lib.path): |
| Christopher Haster |
68:14cc5a81333d | 550 | status() |
| Christopher Haster |
68:14cc5a81333d | 551 | |
| Christopher Haster |
15:a6b1f4e65bf4 | 552 | # Parse/run command |
| Christopher Haster |
15:a6b1f4e65bf4 | 553 | args, remainder = parser.parse_known_args() |
| Christopher Haster |
15:a6b1f4e65bf4 | 554 | status = args.command(args) |
| Christopher Haster |
15:a6b1f4e65bf4 | 555 | sys.exit(status or 0) |
| Christopher Haster |
15:a6b1f4e65bf4 | 556 |