mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Generate better UID
This commit is contained in:
@ -72,8 +72,6 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904
|
|||||||
@click.option("--caller", "-c", help="Caller ID (service).")
|
@click.option("--caller", "-c", help="Caller ID (service).")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, force, caller):
|
def cli(ctx, force, caller):
|
||||||
if not caller and getenv("PLATFORMIO_CALLER"):
|
|
||||||
caller = getenv("PLATFORMIO_CALLER")
|
|
||||||
maintenance.on_platformio_start(ctx, force, caller)
|
maintenance.on_platformio_start(ctx, force, caller)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import uuid
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from os import environ, getenv
|
from os import environ, getenv
|
||||||
from os.path import getmtime, isfile, join
|
from os.path import getmtime, isfile, join
|
||||||
@ -164,6 +165,11 @@ def reset_settings():
|
|||||||
|
|
||||||
|
|
||||||
def get_session_var(name, default=None):
|
def get_session_var(name, default=None):
|
||||||
|
if name == "caller_id" and not SESSION_VARS[name]:
|
||||||
|
if getenv("PLATFORMIO_CALLER"):
|
||||||
|
return getenv("PLATFORMIO_CALLER")
|
||||||
|
elif getenv("C9_UID"):
|
||||||
|
return "C9"
|
||||||
return SESSION_VARS.get(name, default)
|
return SESSION_VARS.get(name, default)
|
||||||
|
|
||||||
|
|
||||||
@ -175,3 +181,13 @@ def set_session_var(name, value):
|
|||||||
def is_disabled_progressbar():
|
def is_disabled_progressbar():
|
||||||
return any([get_session_var("force_option"), util.is_ci(),
|
return any([get_session_var("force_option"), util.is_ci(),
|
||||||
getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true"])
|
getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true"])
|
||||||
|
|
||||||
|
|
||||||
|
def get_cid():
|
||||||
|
cid = get_state_item("cid")
|
||||||
|
if not cid:
|
||||||
|
cid = str(
|
||||||
|
uuid.uuid5(uuid.NAMESPACE_OID, str(
|
||||||
|
getenv("C9_UID") if getenv("C9_UID") else uuid.getnode())))
|
||||||
|
set_state_item("cid", cid)
|
||||||
|
return cid
|
||||||
|
@ -17,7 +17,6 @@ import platform
|
|||||||
import Queue
|
import Queue
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import uuid
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from os import getenv
|
from os import getenv
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
@ -31,8 +30,6 @@ from platformio import __version__, app, exception, util
|
|||||||
|
|
||||||
class TelemetryBase(object):
|
class TelemetryBase(object):
|
||||||
|
|
||||||
MACHINE_ID = str(uuid.uuid5(uuid.NAMESPACE_OID, str(uuid.getnode())))
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._params = {}
|
self._params = {}
|
||||||
|
|
||||||
@ -46,13 +43,6 @@ class TelemetryBase(object):
|
|||||||
if name in self._params:
|
if name in self._params:
|
||||||
del self._params[name]
|
del self._params[name]
|
||||||
|
|
||||||
def get_cid(self):
|
|
||||||
cid = app.get_state_item("cid")
|
|
||||||
if not cid:
|
|
||||||
cid = self.MACHINE_ID
|
|
||||||
app.set_state_item("cid", cid)
|
|
||||||
return cid
|
|
||||||
|
|
||||||
def send(self, hittype):
|
def send(self, hittype):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@ -72,7 +62,7 @@ class MeasurementProtocol(TelemetryBase):
|
|||||||
TelemetryBase.__init__(self)
|
TelemetryBase.__init__(self)
|
||||||
self['v'] = 1
|
self['v'] = 1
|
||||||
self['tid'] = self.TID
|
self['tid'] = self.TID
|
||||||
self['cid'] = self.get_cid()
|
self['cid'] = app.get_cid()
|
||||||
|
|
||||||
self['sr'] = "%dx%d" % click.get_terminal_size()
|
self['sr'] = "%dx%d" % click.get_terminal_size()
|
||||||
self._prefill_screen_name()
|
self._prefill_screen_name()
|
||||||
|
Reference in New Issue
Block a user