This repository was archived by the owner on May 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Make it easier to run local version of PyPI. #536
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# import defusedxml before anything else | ||
from __future__ import print_function | ||
import defusedxml | ||
import defusedxml.xmlrpc | ||
defusedxml.xmlrpc.monkey_patch() | ||
|
@@ -257,14 +258,18 @@ def decode_form(form): | |
d[k] = transmute(v) | ||
return d | ||
|
||
if os.environ.get('PYPI_LEGACY_ALLOW_NO_TLS_FOR_TESTING_PURPOSE_ONLY', 'False') == '1': | ||
def must_tls(fn): | ||
return fn | ||
else: | ||
|
||
def must_tls(fn): | ||
@functools.wraps(fn) | ||
def wrapped(self, *args, **kwargs): | ||
if self.env.get('HTTP_X_FORWARDED_PROTO') != 'https': | ||
raise Forbidden("Must access using HTTPS instead of HTTP") | ||
return fn(self, *args, **kwargs) | ||
return wrapped | ||
def must_tls(fn): | ||
@functools.wraps(fn) | ||
def wrapped(self, *args, **kwargs): | ||
if self.env.get('HTTP_X_FORWARDED_PROTO') != 'https': | ||
raise Forbidden("Must access using HTTPS instead of HTTP") | ||
return fn(self, *args, **kwargs) | ||
return wrapped | ||
|
||
|
||
class MultiWriteFS(fs.multifs.MultiFS): | ||
|
@@ -415,17 +420,20 @@ def __init__(self, handler, env): | |
self.usercookie = None | ||
self.failed = None # error message if initialization already produced a failure | ||
|
||
self.package_bucket = None | ||
if self.config.database_aws_access_key_id and self.config.database_aws_secret_access_key: | ||
self.s3conn = boto.s3.connect_to_region( | ||
"us-west-2", | ||
aws_access_key_id=self.config.database_aws_access_key_id, | ||
aws_secret_access_key=self.config.database_aws_secret_access_key, | ||
) | ||
|
||
self.s3conn = boto.s3.connect_to_region( | ||
"us-west-2", | ||
aws_access_key_id=self.config.database_aws_access_key_id, | ||
aws_secret_access_key=self.config.database_aws_secret_access_key, | ||
) | ||
|
||
self.package_bucket = self.s3conn.get_bucket( | ||
self.config.database_files_bucket, | ||
validate=False, | ||
) | ||
self.package_bucket = self.s3conn.get_bucket( | ||
self.config.database_files_bucket, | ||
validate=False, | ||
) | ||
else: | ||
print("AWS database not fully configured. Getting the package files will be unavailable.", file=sys.stderr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this is mostly indenting, so viewing the diff with |
||
|
||
if self.config.database_docs_bucket is not None: | ||
self.docs_fs = NoDirS3FS( | ||
|
@@ -434,7 +442,10 @@ def __init__(self, handler, env): | |
aws_secret_key=self.config.database_aws_secret_access_key, | ||
) | ||
else: | ||
self.docs_fs = fs.osfs.OSFS(self.config.database_docs_dir) | ||
try: | ||
self.docs_fs = fs.osfs.OSFS(self.config.database_docs_dir) | ||
except Exception as e: | ||
import pdb; pdb.set_trace() | ||
|
||
# XMLRPC request or not? | ||
if self.env.get('CONTENT_TYPE') != 'text/xml': | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the except-pass anyway if fails later if one does not have psycopg2 working.