Skip to content

Commit 4d5126f

Browse files
committed
Fixed script fails if not installed from pip
At the top of the script, the line from github_backup import __version__ gets the script's version number to use if the script is called with the -v or --version flags. The problem is that if the script hasn't been installed via pip (for example I cloned the repo directly to my backup server), the script will fail due to an import exception. Also presumably it will always use the version number from pip even if running a modified version from git or a fork or something, though this does not fix that as I have no idea how to check if it's running the pip installed version or not. But at least the script will now work fine if cloned from git or just copied to another machine. closes josegonzalez#141
1 parent 98919c8 commit 4d5126f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bin/github-backup

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ except ImportError:
4141
from urllib2 import HTTPRedirectHandler
4242
from urllib2 import build_opener
4343

44-
from github_backup import __version__
44+
try:
45+
from github_backup import __version__
46+
VERSION = __version__
47+
except ImportError:
48+
VERSION = 'unknown'
4549

4650
FNULL = open(os.devnull, 'w')
4751

@@ -302,7 +306,7 @@ def parse_args():
302306
help='Clone repositories using SSH instead of HTTPS')
303307
parser.add_argument('-v', '--version',
304308
action='version',
305-
version='%(prog)s ' + __version__)
309+
version='%(prog)s ' + VERSION)
306310
parser.add_argument('--keychain-name',
307311
dest='osx_keychain_item_name',
308312
help='OSX ONLY: name field of password item in OSX keychain that holds the personal access or OAuth token')

0 commit comments

Comments
 (0)