Skip to content

Commit 96c2d71

Browse files
authored
Merge pull request #78 from databio/dev
Release 0.7.2
2 parents 1f033e8 + 49fa766 commit 96c2d71

12 files changed

Lines changed: 98 additions & 16 deletions

File tree

bulker/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.7.1"
1+
__version__ = "0.7.2"

bulker/bulker.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def bulker_load(manifest, cratevars, bcfg, exe_jinja2_template,
443443
manifest_name,
444444
cratevars['tag'])
445445
if not os.path.isabs(crate_path):
446-
crate_path = os.path.join(os.path.dirname(bcfg._file_path), crate_path)
446+
crate_path = os.path.join(os.path.dirname(bcfg["__internal"].file_path), crate_path)
447447

448448
_LOGGER.debug("Crate path: {}".format(crate_path))
449449
_LOGGER.debug("cratevars: {}".format(cratevars))
@@ -483,7 +483,7 @@ def bulker_load(manifest, cratevars, bcfg, exe_jinja2_template,
483483
imp_cratevars['crate'],
484484
imp_cratevars['tag'])
485485
if not os.path.isabs(imp_crate_path):
486-
imp_crate_path = os.path.join(os.path.dirname(bcfg._file_path), imp_crate_path)
486+
imp_crate_path = os.path.join(os.path.dirname(bcfg["__internal"].file_path), imp_crate_path)
487487
if not os.path.exists(imp_crate_path):
488488
_LOGGER.error("Nonexistent crate: '{}' from '{}'. Reloading...".format(imp, imp_crate_path))
489489
reload_import = True
@@ -533,7 +533,7 @@ def host_tool_specific_args(bcfg, pkg, hosttool_arg_key):
533533
if os.path.isabs(pkg["singularity_image_folder"]):
534534
sif = pkg["singularity_image_folder"]
535535
else:
536-
sif = os.path.join(os.path.dirname(bcfg._file_path),
536+
sif = os.path.join(os.path.dirname(bcfg["__internal"].file_path),
537537
pkg["singularity_image_folder"])
538538

539539
pkg["singularity_fullpath"] = os.path.join(
@@ -756,10 +756,10 @@ def bulker_activate(bulker_config, cratelist, echo=False, strict=False, prompt=T
756756
if os.path.basename(shellpath) == "bash":
757757
if strict:
758758
rcfile = mkabs(bulker_config.bulker.rcfile_strict,
759-
os.path.dirname(bulker_config._file_path))
759+
os.path.dirname(bulker_config["__internal"].file_path))
760760
else:
761761
rcfile = mkabs(bulker_config.bulker.rcfile,
762-
os.path.dirname(bulker_config._file_path))
762+
os.path.dirname(bulker_config["__internal"].file_path))
763763

764764
shell_list.append("--rcfile")
765765
shell_list.append(rcfile)
@@ -770,11 +770,11 @@ def bulker_activate(bulker_config, cratelist, echo=False, strict=False, prompt=T
770770
if strict:
771771
rcfolder = mkabs(os.path.join(
772772
os.path.dirname(bulker_config.bulker.rcfile_strict),
773-
"zsh_start_strict"), os.path.dirname(bulker_config._file_path))
773+
"zsh_start_strict"), os.path.dirname(bulker_config["__internal"].file_path))
774774
else:
775775
rcfolder = mkabs(os.path.join(
776776
os.path.dirname(bulker_config.bulker.rcfile_strict),
777-
"zsh_start"), os.path.dirname(bulker_config._file_path))
777+
"zsh_start"), os.path.dirname(bulker_config["__internal"].file_path))
778778

779779
new_env["ZDOTDIR"] = rcfolder
780780
_LOGGER.debug("ZDOTDIR: {}".format(new_env["ZDOTDIR"]))
@@ -844,6 +844,7 @@ def maybe_quote(item):
844844
global PROC
845845
PROC = psutil.Popen(merged_command, shell=True, preexec_fn=os.setsid)
846846
PROC.communicate()
847+
sys.exit(PROC.returncode)
847848
#command[0:0] = ["export", "PATH=\"{}\"".format(newpath)]
848849
#subprocess.call(merged_command)
849850

@@ -1047,12 +1048,12 @@ def prep_load(bulker_config, crate_registry_paths, manifest=None, build=False):
10471048
shell_template_jinja = None
10481049

10491050
exe_template = mkabs(bulker_config.bulker.executable_template,
1050-
os.path.dirname(bulker_config._file_path))
1051+
os.path.dirname(bulker_config["__internal"].file_path))
10511052
build_template = mkabs(bulker_config.bulker.build_template,
1052-
os.path.dirname(bulker_config._file_path))
1053+
os.path.dirname(bulker_config["__internal"].file_path))
10531054
try:
10541055
shell_template = mkabs(bulker_config.bulker.shell_template,
1055-
os.path.dirname(bulker_config._file_path))
1056+
os.path.dirname(bulker_config["__internal"].file_path))
10561057
except AttributeError:
10571058
_LOGGER.error("You need to re-initialize your bulker config or add a 'shell_template' attribute.")
10581059
sys.exit(1)
@@ -1289,7 +1290,7 @@ def main():
12891290
manifest_name,
12901291
cratevars['tag'])
12911292
if not os.path.isabs(crate_path):
1292-
crate_path = os.path.join(os.path.dirname(bcfg._file_path), crate_path)
1293+
crate_path = os.path.join(os.path.dirname(bulker_config["__internal"].file_path), crate_path)
12931294
print("Crate path: {}".format(crate_path))
12941295

12951296

@@ -1359,13 +1360,18 @@ def main():
13591360
manifest, cratevars, exe_template_jinja, shell_template_jinja, build_template_jinja = prep_load(
13601361
bulker_config, args.crate_registry_paths, args.manifest, args.build)
13611362

1362-
bulker_load(manifest, cratevars, bulker_config,
1363+
try:
1364+
bulker_load(manifest, cratevars, bulker_config,
13631365
exe_jinja2_template=exe_template_jinja,
13641366
shell_jinja2_template=shell_template_jinja,
13651367
crate_path=args.path,
13661368
build=build_template_jinja,
13671369
force=args.force,
13681370
recurse=args.recurse)
1371+
except Exception as e:
1372+
print(f'Bulker load failed: {e}')
1373+
sys.exit(1)
1374+
13691375

13701376
if args.command == "reload":
13711377
bulker_config.make_writable()

bulker/templates/start.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
source "${BULKERSHELLRC}"
2-
echo $BULKERPROMPT
32
if [ -z ${BULKERPROMPT+x} ]; then echo "No prompt change"; else PS1="${BULKERPROMPT}"; fi
43
export PATH="${BULKERPATH}:${PATH}"

docs/changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Changelog
22

3+
## [0.7.2] -- 2021-06-24
4+
- Update to yacman 0.8.0, fixing references to internal config attributes.
5+
- Add documentation and clarity for the `shell_prompt` option
6+
- Fixed bug with relative crate root folders.
7+
38
## [0.7.1] -- 2021-03-03
4-
-- Fixed bug in bulker reload.
9+
- Fixed bug in bulker reload.
510

611
## [0.7.0] -- 2021-03-02
712
- EXPERIMENTAL: Added `bulker cwl2man` to create a bulker manifest from a CWL file.

docs/custom_prompts.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Customizing bulker prompts
2+
3+
By default, when you activate a crate, bulker will change your prompt. You can customize it by specifying the `shell_prompt` attribute in your bulker config. *Make sure you enclose the value in single quotes*; if you use double-quotes the parser will re-escape your prompt escape sequences and break stuff. Here are some examples:
4+
5+
In these examples we'll activate the crate like this:
6+
7+
```console
8+
bulker activate databio/lab
9+
```
10+
11+
The variables that could be displayed are these:
12+
13+
- namespace: `databio`
14+
- crate name: `lab`
15+
- username: `nsheff`
16+
- host: `zither`
17+
- working directory: `code`
18+
19+
# Default prompt
20+
21+
The default bulker prompt shows you the name of the crate you've activated, colored in yellow. Bulker uses `\b` to indicate the name of the bulker namespace and crate. The default prompt is the equivalent of putting this in your config:
22+
23+
```yaml
24+
shell_prompt: '\[\033[01;93m\]\b|\[\033[00m\]\[\033[01;34m\]\w\[\033[00m\]\$ '
25+
```
26+
27+
![](img/prompts/default.png)
28+
29+
30+
## Include username and hostname
31+
32+
In addition the bulker-provided `\b`, there are lots of other shell-provided variables you can use, like `\u` for username and `\h` for hostname, and `\W` for working directory path. You can look up lists of these by searching for *customizing bash PS1 prompt*. Here's a simple sample using *username* and *hostname*:
33+
34+
```yaml
35+
shell_prompt: '[\u@\h(\b) \W] $ '
36+
```
37+
38+
![](img/prompts/prompt1.png)
39+
40+
## Change colors
41+
42+
You can al;so use any terminal colors compatible with your terminal.
43+
44+
45+
```yaml
46+
shell_prompt: '\u@\h|\e[94m\b\[\e[00m\]:\e[90m\W\e[39m $ '
47+
```
48+
49+
![](img/prompts/prompt2.png)
50+
51+
52+
## Emoji
53+
54+
Yes, you can even put emoji in your prompt, if that's your thing:
55+
56+
```yaml
57+
shell_prompt: '⚓ \e[94m\b\[\e[00m\]:\e[90m\W\e[39m $ '
58+
```
59+
60+
![](img/prompts/prompt3.png)
61+
62+
63+
## Date/time
64+
65+
This example uses a custom date/time format along with 256-color codes:
66+
67+
```yaml
68+
shell_prompt: '\D{%y/%m/%d %H:%M}⚓ \e[38;5;141m\b\[\e[00m\]:\e[38;5;29m\W\e[39m $ '
69+
```
70+
71+
![](img/prompts/prompt4.png)

docs/img/prompts/default.png

6.88 KB
Loading

docs/img/prompts/prompt1.png

10.8 KB
Loading

docs/img/prompts/prompt2.png

10.9 KB
Loading

docs/img/prompts/prompt3.png

8.58 KB
Loading

docs/img/prompts/prompt4.png

13.5 KB
Loading

0 commit comments

Comments
 (0)