Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
3148be06
Commit
3148be06
authored
Nov 08, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove sdk from coco
parent
7b530dee
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
8 additions
and
144 deletions
+8
-144
app.py
coco/app.py
+1
-1
auth.py
coco/auth.py
+0
-131
exception.py
coco/exception.py
+0
-9
httpd.py
coco/httpd.py
+3
-1
interactive.py
coco/interactive.py
+3
-1
sdk.py
coco/sdk.py
+0
-0
utils.py
coco/utils.py
+1
-1
No files found.
coco/app.py
View file @
3148be06
...
@@ -2,12 +2,12 @@ import os
...
@@ -2,12 +2,12 @@ import os
import
time
import
time
import
threading
import
threading
import
logging
import
logging
from
jms.service
import
AppService
from
.config
import
Config
from
.config
import
Config
from
.sshd
import
SSHServer
from
.sshd
import
SSHServer
from
.httpd
import
HttpServer
from
.httpd
import
HttpServer
from
.logging
import
create_logger
from
.logging
import
create_logger
from
.sdk
import
AppService
__version__
=
'0.4.0'
__version__
=
'0.4.0'
...
...
coco/auth.py
deleted
100644 → 0
View file @
7b530dee
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import
os
import
logging
from
.
import
utils
from
.exception
import
LoadAccessKeyError
class
AccessKeyAuth
(
object
):
def
__init__
(
self
,
access_key
):
self
.
id
=
access_key
.
id
self
.
secret
=
access_key
.
secret
def
sign_request
(
self
,
req
):
req
.
headers
[
'Date'
]
=
utils
.
http_date
()
signature
=
utils
.
make_signature
(
self
.
secret
)
req
.
headers
[
'Authorization'
]
=
"Sign {0}:{1}"
.
format
(
self
.
id
,
signature
)
return
req
class
AccessKey
(
object
):
def
__init__
(
self
,
id
=
None
,
secret
=
None
):
self
.
id
=
id
self
.
secret
=
secret
@staticmethod
def
clean
(
value
,
sep
=
':'
,
silent
=
False
):
try
:
id
,
secret
=
value
.
split
(
sep
)
except
(
AttributeError
,
ValueError
)
as
e
:
if
not
silent
:
raise
LoadAccessKeyError
(
e
)
return
''
,
''
else
:
return
id
,
secret
@classmethod
def
load_from_val
(
cls
,
val
,
**
kwargs
):
id
,
secret
=
cls
.
clean
(
val
,
**
kwargs
)
return
cls
(
id
=
id
,
secret
=
secret
)
@classmethod
def
load_from_env
(
cls
,
env
,
**
kwargs
):
value
=
os
.
environ
.
get
(
env
)
id
,
secret
=
cls
.
clean
(
value
,
**
kwargs
)
return
cls
(
id
=
id
,
secret
=
secret
)
@classmethod
def
load_from_f
(
cls
,
f
,
**
kwargs
):
value
=
''
if
isinstance
(
f
,
str
)
and
os
.
path
.
isfile
(
f
):
f
=
open
(
f
)
if
hasattr
(
f
,
'read'
):
for
line
in
f
:
if
line
and
not
line
.
strip
()
.
startswith
(
'#'
):
value
=
line
.
strip
()
break
f
.
close
()
id
,
secret
=
cls
.
clean
(
value
,
**
kwargs
)
return
cls
(
id
=
id
,
secret
=
secret
)
def
save_to_f
(
self
,
f
,
silent
=
False
):
if
isinstance
(
f
,
str
):
f
=
open
(
f
,
'w'
)
try
:
f
.
write
(
str
(
'{0}:{1}'
.
format
(
self
.
id
,
self
.
secret
)))
except
IOError
as
e
:
logging
.
error
(
'Save access key error: {}'
.
format
(
e
))
if
not
silent
:
raise
finally
:
f
.
close
()
def
__bool__
(
self
):
return
bool
(
self
.
id
and
self
.
secret
)
def
__str__
(
self
):
return
'{0}:{1}'
.
format
(
self
.
id
,
self
.
secret
)
def
__repr__
(
self
):
return
'{0}:{1}'
.
format
(
self
.
id
,
self
.
secret
)
class
AppAccessKey
(
AccessKey
):
"""使用Access key来认证"""
def
__init__
(
self
,
id
=
None
,
secret
=
None
):
super
()
.
__init__
(
id
=
id
,
secret
=
secret
)
self
.
app
=
None
def
set_app
(
self
,
app
):
self
.
app
=
app
@property
def
_key_env
(
self
):
return
self
.
app
.
config
[
'ACCESS_KEY_ENV'
]
@property
def
_key_val
(
self
):
return
self
.
app
.
config
[
'ACCESS_KEY'
]
@property
def
_key_file
(
self
):
return
self
.
app
.
config
[
'ACCESS_KEY_FILE'
]
def
load_from_conf_env
(
self
,
sep
=
':'
,
silent
=
False
):
return
super
()
.
load_from_env
(
self
.
_key_env
,
sep
=
sep
,
silent
=
silent
)
def
load_from_conf_val
(
self
,
sep
=
':'
,
silent
=
False
):
return
super
()
.
load_from_val
(
self
.
_key_val
,
sep
=
sep
,
silent
=
silent
)
def
load_from_conf_file
(
self
,
sep
=
':'
,
silent
=
False
):
return
super
()
.
load_from_f
(
self
.
_key_file
,
sep
=
sep
,
silent
=
silent
)
def
load
(
self
,
**
kwargs
):
"""Should return access_key_id, access_key_secret"""
for
method
in
[
self
.
load_from_conf_env
,
self
.
load_from_conf_val
,
self
.
load_from_conf_file
]:
try
:
return
method
(
**
kwargs
)
except
LoadAccessKeyError
:
continue
return
None
def
save_to_file
(
self
):
return
super
()
.
save_to_f
(
self
.
_key_file
)
\ No newline at end of file
coco/exception.py
View file @
3148be06
...
@@ -5,13 +5,4 @@ class PermissionFailed(Exception):
...
@@ -5,13 +5,4 @@ class PermissionFailed(Exception):
pass
pass
class
LoadAccessKeyError
(
Exception
):
pass
class
RequestError
(
Exception
):
pass
class
ResponseError
(
Exception
):
pass
coco/httpd.py
View file @
3148be06
...
@@ -9,7 +9,9 @@ import tornado.httpclient
...
@@ -9,7 +9,9 @@ import tornado.httpclient
import
tornado.ioloop
import
tornado.ioloop
import
tornado.gen
import
tornado.gen
from
.models
import
User
,
Request
,
Client
,
WSProxy
# Todo: Remove for future
from
jms.models
import
User
from
.models
import
Request
,
Client
,
WSProxy
from
.interactive
import
InteractiveServer
from
.interactive
import
InteractiveServer
...
...
coco/interactive.py
View file @
3148be06
...
@@ -3,11 +3,13 @@ import logging
...
@@ -3,11 +3,13 @@ import logging
import
socket
import
socket
import
threading
import
threading
# Todo remove
from
jms.models
import
Asset
,
SystemUser
from
.
import
char
from
.
import
char
from
.utils
import
TtyIOParser
,
wrap_with_line_feed
as
wr
,
\
from
.utils
import
TtyIOParser
,
wrap_with_line_feed
as
wr
,
\
wrap_with_primary
as
primary
,
wrap_with_warning
as
warning
wrap_with_primary
as
primary
,
wrap_with_warning
as
warning
from
.forward
import
ProxyServer
from
.forward
import
ProxyServer
from
.models
import
Asset
,
SystemUser
from
.session
import
Session
from
.session
import
Session
logger
=
logging
.
getLogger
(
__file__
)
logger
=
logging
.
getLogger
(
__file__
)
...
...
coco/sdk.py
deleted
100644 → 0
View file @
7b530dee
This diff is collapsed.
Click to expand it.
coco/utils.py
View file @
3148be06
...
@@ -253,7 +253,7 @@ def wrap_with_title(text):
...
@@ -253,7 +253,7 @@ def wrap_with_title(text):
def
b64encode_as_string
(
data
):
def
b64encode_as_string
(
data
):
return
to_string
(
base64
.
b64encode
(
data
)
)
return
base64
.
b64encode
(
data
)
.
decode
(
"utf-8"
)
def
split_string_int
(
s
):
def
split_string_int
(
s
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment