Skip to content

Commit

Permalink
Merge pull request #33 from rcaloras/1.1.1-dev
Browse files Browse the repository at this point in the history
1.1.1 dev
  • Loading branch information
rcaloras authored Aug 22, 2016
2 parents 651dfd1 + 0adce10 commit f78f23d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 47 deletions.
14 changes: 9 additions & 5 deletions bashhub/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ def search(limit=None, path=None, query=None, system_name=None, unique=None):
except Exception as error:
if r.status_code in (403, 401):
print("Permissons Issue. Run bashhub setup to re-login.")
print(
"Sorry, an error occurred communicating with Bashhub. Response Code: "
+ str(r.status_code))
else:
print(
"Sorry, an error occurred communicating with Bashhub. Response Code: "
+ str(r.status_code))
return []


Expand All @@ -222,11 +223,14 @@ def get_status_view(process_id, start_time):
r = requests.get(url, params=payload, headers=json_auth_headers())
status_view_json = json.dumps(r.json())
return StatusView.from_JSON(status_view_json)
except ConnectionError as error:
print "Sorry, looks like there's a connection error"
return None
except Exception as error:
if r.status_code in (403, 401):
print("Permissons Issue. Run bashhub setup to re-login.")
else:
print(
"Sorry, looks like there's a connection error: " + str(error))

"Sorry, an error occurred communicating with Bashhub. Response Code: "
+ str(r.status_code))
return None
20 changes: 14 additions & 6 deletions bashhub/shell/deps/bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Author: Ryan Caloras ([email protected])
# Forked from Original Author: Glyph Lefkowitz
#
# V0.3.0
# V0.3.1
#

# General Usage:
Expand Down Expand Up @@ -42,7 +42,7 @@ __bp_imported="defined"

# Should be available to each precmd and preexec
# functions, should they want it.
__bp_last_command_ret_value="$?"
__bp_last_ret_value="$?"

# Command to set our preexec trap. It's invoked once via
# PROMPT_COMMAND and then removed.
Expand Down Expand Up @@ -87,7 +87,7 @@ __bp_interactive_mode() {
# It will invoke any functions defined in the precmd_functions array.
__bp_precmd_invoke_cmd() {

# Should be available to each precmd function, should it want it.
# Save the returned value from our last command
__bp_last_ret_value="$?"

# For every function defined in our function array. Invoke it.
Expand Down Expand Up @@ -234,9 +234,17 @@ __bp_install() {
# Adjust our HISTCONTROL Variable if needed.
__bp_adjust_histcontrol

# Set so debug trap will work be invoked in subshells.
set -o functrace > /dev/null 2>&1
shopt -s extdebug > /dev/null 2>&1

# Issue #25. Setting debug trap for subshells causes sessions to exit for
# backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash.
#
# Disabling this by default. It can be enabled by setting this variable.
if [[ -n "$__bp_enable_subshells" ]]; then

# Set so debug trap will work be invoked in subshells.
set -o functrace > /dev/null 2>&1
shopt -s extdebug > /dev/null 2>&1
fi;


local existing_prompt_command
Expand Down
2 changes: 1 addition & 1 deletion bashhub/shell/deps/lib-bashhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ __bh_process_command() {
__bh_check_bashhub_installation() {
local ret
ret=0
if [[ -n "$BASH_VERSION" && "$(trap)" != *"__bp_preexec_invoke_exec"* ]]; then
if [[ -n "$BASH_VERSION" && -n "$__bp_enable_subshells" && "$(trap)" != *"__bp_preexec_invoke_exec"* ]]; then
echo "Bashhub's preexec hook is being overriden and is not saving commands. Please resolve what may be holding the DEBUG trap."
ret=1
elif [[ ! -f "$BH_HOME_DIRECTORY/config" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion bashhub/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.1.0'
__version__ = '1.1.1'
2 changes: 1 addition & 1 deletion install-bashhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ zshprofile=~/.zshrc

# Optional parameter to specify a github branch
# to pull from.
github_branch=${1:-'1.1.0'}
github_branch=${1:-'1.1.1'}

install_bashhub() {
check_dependencies
Expand Down
33 changes: 0 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
from setuptools import setup, find_packages
import install_bashhub
import sys
from setuptools.command.install import install
from setuptools.command.develop import develop


def postinstall(command_subclass):
"""A decorator for classes subclassing one of the setuptools commands.
It modifies the run() method so that it runs our post install setup.
"""
orig_run = command_subclass.run

def modified_run(self):
# Need to run bashhub-setup here
#
orig_run(self)

command_subclass.run = modified_run
return command_subclass


@postinstall
class BashhubInstall(install):
pass


@postinstall
class BashhubDevelop(develop):
pass


exec (open('bashhub/version.py').read())

Expand All @@ -51,8 +22,4 @@ class BashhubDevelop(develop):
'console_scripts': ['bh=bashhub.bh:main',
'bashhub=bashhub.bashhub:main']
},
cmdclass={
'install': BashhubInstall,
'develop': BashhubDevelop
},
zip_safe=False)
3 changes: 3 additions & 0 deletions tests/shell/lib-bashhub.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ teardown() {

@test "__bh_check_bashhub_installation should find issues and run only once." {

# Enable subshells for these checks to work
export __bp_enable_subshells="true"

# Bash but no trap.
run '__bh_check_bashhub_installation'
[[ $status == 1 ]]
Expand Down

0 comments on commit f78f23d

Please sign in to comment.