forked from platformio/platformio-core
Switch to Python's time module
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from platformio import __accounts_api__, app, util
|
from platformio import __accounts_api__, app
|
||||||
from platformio.exception import PlatformioException
|
from platformio.exception import PlatformioException
|
||||||
from platformio.http import HTTPClient, HTTPClientError
|
from platformio.http import HTTPClient, HTTPClientError
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class AccountClient(HTTPClient): # pylint:disable=too-many-public-methods
|
|||||||
return os.environ.get("PLATFORMIO_AUTH_TOKEN")
|
return os.environ.get("PLATFORMIO_AUTH_TOKEN")
|
||||||
auth = app.get_state_item("account", {}).get("auth", {})
|
auth = app.get_state_item("account", {}).get("auth", {})
|
||||||
if auth.get("access_token") and auth.get("access_token_expire"):
|
if auth.get("access_token") and auth.get("access_token_expire"):
|
||||||
if auth.get("access_token_expire") > util.get_timestamp():
|
if auth.get("access_token_expire") > time.time():
|
||||||
return auth.get("access_token")
|
return auth.get("access_token")
|
||||||
if auth.get("refresh_token"):
|
if auth.get("refresh_token"):
|
||||||
try:
|
try:
|
||||||
|
@@ -18,9 +18,10 @@ import json
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import socket
|
import socket
|
||||||
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from platformio import __version__, exception, fs, proc, util
|
from platformio import __version__, exception, fs, proc
|
||||||
from platformio.compat import IS_WINDOWS, hashlib_encode_data
|
from platformio.compat import IS_WINDOWS, hashlib_encode_data
|
||||||
from platformio.package.lockfile import LockFile
|
from platformio.package.lockfile import LockFile
|
||||||
from platformio.project.config import ProjectConfig
|
from platformio.project.config import ProjectConfig
|
||||||
@@ -253,7 +254,7 @@ def get_cid():
|
|||||||
cid = str(cid)
|
cid = str(cid)
|
||||||
if IS_WINDOWS or os.getuid() > 0: # pylint: disable=no-member
|
if IS_WINDOWS or os.getuid() > 0: # pylint: disable=no-member
|
||||||
set_state_item("cid", cid)
|
set_state_item("cid", cid)
|
||||||
set_state_item("created_at", int(util.get_timestamp()))
|
set_state_item("created_at", int(time.time()))
|
||||||
return cid
|
return cid
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@@ -64,15 +63,9 @@ class PlatformRunMixin:
|
|||||||
if not os.path.isfile(variables["build_script"]):
|
if not os.path.isfile(variables["build_script"]):
|
||||||
raise BuildScriptNotFound(variables["build_script"])
|
raise BuildScriptNotFound(variables["build_script"])
|
||||||
|
|
||||||
started_at = time.time()
|
telemetry.log_platform_run(self, self.config, variables["pioenv"], targets)
|
||||||
result = self._run_scons(variables, targets, jobs)
|
result = self._run_scons(variables, targets, jobs)
|
||||||
telemetry.log_platform_run(
|
|
||||||
self,
|
|
||||||
self.config,
|
|
||||||
variables["pioenv"],
|
|
||||||
targets,
|
|
||||||
elapsed_time=time.time() - started_at,
|
|
||||||
)
|
|
||||||
assert "returncode" in result
|
assert "returncode" in result
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@@ -77,7 +77,6 @@ def system_info_cmd(json_output):
|
|||||||
).get_installed()
|
).get_installed()
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
click.echo(
|
click.echo(
|
||||||
json.dumps(data)
|
json.dumps(data)
|
||||||
if json_output
|
if json_output
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import base64
|
|
||||||
import datetime
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import math
|
import math
|
||||||
@@ -168,10 +167,6 @@ def items_in_list(needle, haystack):
|
|||||||
return set(needle) & set(haystack)
|
return set(needle) & set(haystack)
|
||||||
|
|
||||||
|
|
||||||
def get_timestamp(utc=True):
|
|
||||||
return datetime.datetime.now(datetime.timezone.utc if utc else None).timestamp()
|
|
||||||
|
|
||||||
|
|
||||||
def parse_datetime(datestr):
|
def parse_datetime(datestr):
|
||||||
if "T" in datestr and "Z" in datestr:
|
if "T" in datestr and "Z" in datestr:
|
||||||
return datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%SZ")
|
return datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
@@ -211,12 +206,3 @@ def humanize_duration_time(duration):
|
|||||||
def strip_ansi_codes(text):
|
def strip_ansi_codes(text):
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
return click._compat.strip_ansi(text)
|
return click._compat.strip_ansi(text)
|
||||||
|
|
||||||
|
|
||||||
def decrypt_message(key, message):
|
|
||||||
result = ""
|
|
||||||
message = bytearray(base64.b64decode(message))
|
|
||||||
for i, c in enumerate(message):
|
|
||||||
key_c = key[i % len(key)]
|
|
||||||
result += chr((256 + c - ord(key_c)) % 256)
|
|
||||||
return result
|
|
||||||
|
Reference in New Issue
Block a user