Comments (4)
I added authentication to my local copy based on this: http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im
bitbucket username and password were hardcoded in the base64string lines... obviously not ideal.
Here's the diff:
diff --git a/migrate.py b/migrate.py
old mode 100644
new mode 100755
index 95e1dda..ef5d5bc
--- a/migrate.py
+++ b/migrate.py
@@ -19,7 +19,7 @@ from datetime import datetime, timedelta
import urllib2
import time
import getpass
-
+import base64
import sys
try:
@@ -121,7 +121,10 @@ def get_comments(issue):
Fetch the comments for an issue
'''
url = "https://api.bitbucket.org/1.0/repositories/%s/%s/issues/%s/comments/" % (options.bitbucket_username, options.bitbucket_repo, issu
- result = json.loads(urllib2.urlopen(url).read())
+ request = urllib2.Request(url)
+ base64string = base64.encodestring('%s:%s' % ('', '')).replace('\n','')
+ request.add_header("Authorization", "Basic %s" % base64string)
+ result = json.loads(urllib2.urlopen(request).read())
comments = []
for comment in result:
@@ -143,7 +146,10 @@ issues = []
while True:
url = "https://api.bitbucket.org/1.0/repositories/%s/%s/issues/?start=%d" % (options.bitbucket_username, options.bitbucket_repo, options
try:
- response = urllib2.urlopen(url)
+ request = urllib2.Request(url)
+ base64string = base64.encodestring('%s:%s' % ('','')).replace('\n','')
+ request.add_header("Authorization", "Basic %s" % base64string)
+ response = urllib2.urlopen(request)
except urllib2.HTTPError as ex:
raise ValueError(
'Problem trying to connect to bitbucket ({url}): {ex} '
from bitbucket-issue-migration.
#22 tackles this. Waiting for it to be rebased before merging.
from bitbucket-issue-migration.
If a user submits BB creds, but the BB repo is public, then we shouldn't worry about whether the user's BB creds are authentic, we should just use the public API to grab the issues without authenticating.
So probably the workflow is:
- regardless of whether the user provided BB creds, we should try the BB repo without auth
- only if we get back a 401 do we check for BB auth creds--if the user didn't include them, then complain
- if the user included BB auth creds, and we already know it's not a public repo, then we try again to access it
- if we still get a 404 or 401, complain appropriately to the user
from bitbucket-issue-migration.
Fixed in #59
from bitbucket-issue-migration.
Related Issues (20)
- Support for attachments? HOT 12
- Repeated failures verifying github issue import HOT 6
- Proposal: Truncate all labels to 50 characters HOT 1
- dry-run crashes in milestone code HOT 1
- shorter/prettier style for gh issues HOT 5
- Doesn't work for private Github repos HOT 3
- Cannot install dependencies because venv tool deprecated. HOT 1
- KeyError assuming "username" key HOT 3
- Failed to POST due to unexpected HTTP status code: 410 HOT 2
- Import crashes due to name clash between default labels and imported labels HOT 1
- Github rejects comments where the body is just a newline
- Creates invalid BitBucket user links for users without username HOT 2
- Read user mapping from file HOT 1
- Properly attribute comments to users HOT 3
- Permission denied if issues are private HOT 3
- Support bitbucket priorities
- Does not support images within issue comments
- No such file or directory: '' HOT 3
- Older issues that reference newer issues don't automatically link
- Does this close the Bitbucket issues? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitbucket-issue-migration.