Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
14592221
Commit
14592221
authored
10 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
minor cleanup
parent
30dc1280
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
internimsclient.py
+1
-1
1 addition, 1 deletion
internimsclient.py
nimsapi.py
+5
-6
5 additions, 6 deletions
nimsapi.py
nimsapi.wsgi
+3
-2
3 additions, 2 deletions
nimsapi.wsgi
nimsapiutil.py
+2
-2
2 additions, 2 deletions
nimsapiutil.py
with
11 additions
and
11 deletions
internimsclient.py
+
1
−
1
View file @
14592221
...
...
@@ -5,7 +5,7 @@
import
logging
import
logging.config
log
=
logging
.
getLogger
(
'
internims
'
)
logging
.
getLogger
(
'
requests
'
).
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
'
urllib3
'
).
setLevel
(
logging
.
WARNING
)
# silence Requests library logging
import
re
import
json
...
...
This diff is collapsed.
Click to expand it.
nimsapi.py
+
5
−
6
View file @
14592221
...
...
@@ -13,7 +13,6 @@ import uuid
import
hashlib
import
tarfile
import
webapp2
import
zipfile
import
markdown
import
bson.json_util
import
webapp2_extras.routes
...
...
@@ -142,17 +141,17 @@ class NIMSAPI(nimsapiutil.NIMSRequestHandler):
stage_path
=
self
.
app
.
config
[
'
stage_path
'
]
with
tempfile
.
TemporaryDirectory
(
prefix
=
'
.tmp
'
,
dir
=
stage_path
)
as
tempdir_path
:
hash_
=
hashlib
.
md5
()
upload_
filepath
=
os
.
path
.
join
(
tempdir_path
,
filename
)
with
open
(
upload_
filepath
,
'
wb
'
)
as
upload_file
:
filepath
=
os
.
path
.
join
(
tempdir_path
,
filename
)
with
open
(
filepath
,
'
wb
'
)
as
upload_file
:
for
chunk
in
iter
(
lambda
:
self
.
request
.
body_file
.
read
(
2
**
20
),
''
):
hash_
.
update
(
chunk
)
upload_file
.
write
(
chunk
)
if
hash_
.
hexdigest
()
!=
self
.
request
.
headers
[
'
Content-MD5
'
]:
self
.
abort
(
400
,
'
Content-MD5 mismatch.
'
)
if
not
tarfile
.
is_tarfile
(
upload_filepath
)
and
not
zipfile
.
is_zipfile
(
upload_
filepath
):
if
not
tarfile
.
is_tarfile
(
filepath
):
self
.
abort
(
415
)
log
.
info
(
'
upload from %s: %s [%s]
'
%
(
self
.
request
.
user_agent
,
os
.
path
.
basename
(
upload_filepath
)
,
hrsize
(
self
.
request
.
content_length
)))
os
.
rename
(
upload_
filepath
,
os
.
path
.
join
(
stage_path
,
str
(
uuid
.
uuid1
())
+
'
_
'
+
filename
))
# add UUID to prevent clobbering files
log
.
info
(
'
upload from %s: %s [%s]
'
%
(
self
.
request
.
user_agent
,
filename
,
hrsize
(
self
.
request
.
content_length
)))
os
.
rename
(
filepath
,
os
.
path
.
join
(
stage_path
,
str
(
uuid
.
uuid1
())
+
'
_
'
+
filename
))
# add UUID to prevent clobbering files
def
download
(
self
):
if
self
.
request
.
method
==
'
OPTIONS
'
:
...
...
This diff is collapsed.
Click to expand it.
nimsapi.wsgi
+
3
−
2
View file @
14592221
...
...
@@ -9,9 +9,10 @@ configfile = '../production.ini'
config = ConfigParser.ConfigParser()
config.read(configfile)
site.addsitedir(os.path.join(config.get('nims', 'virtualenv'), 'lib
', '
python2.7
', '
site-packages'))
site.addsitedir(os.path.join(config.get('nims', 'virtualenv'), 'lib
/
python2.7
/
site-packages'))
sys.path.append(config.get('nims', 'here'))
os.environ['PYTHON_EGG_CACHE'] = config.get('nims', 'python_egg_cache')
os.umask(0o022)
import pymongo
import Crypto.Random
...
...
@@ -33,7 +34,7 @@ privkey_file = config.get('nims', 'ssl_key')
try:
privkey = Crypto.PublicKey.RSA.importKey(open(privkey_file).read())
except Exception:
log.warn(privkey_file + 'is not a valid private SSL key file')
log.warn(privkey_file + '
is not a valid private SSL key file')
privkey = None
else:
log.info('successfully loaded private SSL key from ' + privkey_file)
...
...
This diff is collapsed.
Click to expand it.
nimsapiutil.py
+
2
−
2
View file @
14592221
...
...
@@ -2,7 +2,7 @@
import
logging
log
=
logging
.
getLogger
(
'
nimsapi
'
)
logging
.
getLogger
(
'
requests
'
).
setLevel
(
logging
.
WARNING
)
# silence Requests library logging
logging
.
getLogger
(
'
urllib3
'
).
setLevel
(
logging
.
WARNING
)
# silence Requests library logging
import
json
import
base64
...
...
@@ -169,7 +169,7 @@ class NIMSRequestHandler(webapp2.RequestHandler):
else
:
if
self
.
request
.
method
==
'
OPTIONS
'
:
return
self
.
options
()
r
=
requests
.
request
(
self
.
request
.
method
,
self
.
target_uri
,
params
=
self
.
params
,
data
=
self
.
request
.
body
,
headers
=
self
.
headers
,
verify
=
False
)
r
=
requests
.
request
(
self
.
request
.
method
,
self
.
target_uri
,
params
=
self
.
params
,
data
=
self
.
request
.
body
,
headers
=
self
.
headers
)
if
r
.
status_code
!=
200
:
self
.
abort
(
r
.
status_code
,
'
InterNIMS p2p err:
'
+
r
.
reason
)
self
.
response
.
write
(
r
.
content
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment