Initial support for Eclipse Che

This commit is contained in:
Ivan Kravets
2016-10-10 20:59:47 +03:00
parent 5f83861f52
commit c2ee36a4d7
3 changed files with 16 additions and 4 deletions

View File

@ -14,7 +14,7 @@
import sys
VERSION = (3, 2, "0a5")
VERSION = (3, 2, "0a6")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -21,6 +21,7 @@ from os import environ, getenv, listdir, remove
from os.path import dirname, getmtime, isdir, isfile, join
from time import time
import requests
from lockfile import LockFile
from platformio import __version__, util
@ -261,9 +262,18 @@ def is_disabled_progressbar():
def get_cid():
cid = get_state_item("cid")
if not cid:
_uid = None
if getenv("C9_UID"):
_uid = getenv("C9_UID")
elif getenv("CHE_API_ENDPOINT"):
try:
_uid = requests.get("{api}/user?token={token}".format(
api=getenv("CHE_API_ENDPOINT"), token=getenv(
"USER_TOKEN"))).json().get("id")
except: # pylint: disable=bare-except
pass
cid = str(
uuid.UUID(bytes=hashlib.md5(
str(getenv("C9_UID")
if getenv("C9_UID") else uuid.getnode())).digest()))
uuid.UUID(bytes=hashlib.md5(str(_uid if _uid else uuid.getnode()))
.digest()))
set_state_item("cid", cid)
return cid

View File

@ -56,6 +56,8 @@ def on_platformio_start(ctx, force, caller):
caller = "C9"
elif getenv("USER") == "cabox":
caller = "CA"
elif getenv("CHE_API_ENDPOINT"):
caller = "Che"
app.set_session_var("command_ctx", ctx)
app.set_session_var("force_option", force)