Skip to content

Commit

Permalink
python 3 fixes for samkuehn#36
Browse files Browse the repository at this point in the history
  • Loading branch information
samkuehn committed May 22, 2015
1 parent a9c2bb1 commit e8de591
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ docs/_build/

# PyBuilder
target/
.idea
25 changes: 17 additions & 8 deletions backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import datetime
import os
import sys
import urllib
from getpass import getpass

import bitbucket
Expand All @@ -13,6 +12,15 @@
except ImportError:
from urllib2 import HTTPError, URLError

try:
from urllib.parse import quote
except ImportError:
from urllib import quote

try:
input = raw_input
except NameError:
pass

_verbose = False
_quiet = False
Expand Down Expand Up @@ -59,7 +67,7 @@ def compress(repo, location):
Creates a TAR.GZ file with all contents cloned by this script.
"""
os.chdir(location)
debug("Compressing repositories in [%s]..." % (location), True)
debug("Compressing repositories in [%s]..." % location, True)
exec_cmd("tar -zcvf bitbucket-backup-%s-%s.tar.gz `ls -d *`" % (repo.get('owner'), datetime.datetime.now().strftime('%Y%m%d%H%m%s')))
debug("Cleaning up...", True)
for d in os.listdir(location):
Expand All @@ -74,10 +82,10 @@ def clone_repo(repo, backup_dir, http, username, password, mirror=False, with_wi
slug = repo.get('slug')
owner = repo.get('owner')

owner_url = urllib.quote(owner)
username_url = urllib.quote(username)
password_url = urllib.quote(password)
slug_url = urllib.quote(slug)
owner_url = quote(owner)
username_url = quote(username)
password_url = quote(password)
slug_url = quote(slug)
command = None
if scm == 'hg':
if http:
Expand Down Expand Up @@ -148,13 +156,13 @@ def main():
if _quiet:
_verbose = False # override in case both are selected
if not username:
username = raw_input('Enter bitbucket username: ')
username = input('Enter bitbucket username: ')
owner = args.team if args.team else username
if not password:
if not args.skip_password:
password = getpass(prompt='Enter your bitbucket password: ')
if not location:
location = raw_input('Enter local location to backup to: ')
location = input('Enter local location to backup to: ')
location = os.path.abspath(location)

# ok to proceed
Expand Down Expand Up @@ -191,6 +199,7 @@ def main():
except:
if not _quiet:
import traceback

traceback.print_exc()
exit("Unknown error.", 11) # EAGAIN - Try again

Expand Down

0 comments on commit e8de591

Please sign in to comment.