mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Better detecting of Continuous Integration system
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
import stat
|
||||
from glob import glob
|
||||
from os import chmod, environ, makedirs, remove
|
||||
from os import chmod, getenv, makedirs, remove
|
||||
from os.path import abspath, basename, isdir, isfile, join
|
||||
from shutil import copyfile, copytree, rmtree
|
||||
from tempfile import mkdtemp
|
||||
@ -59,7 +59,7 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913
|
||||
build_dir, keep_build_dir, project_conf, verbose):
|
||||
|
||||
if not src:
|
||||
src = environ.get("PLATFORMIO_CI_SRC", "").split(":")
|
||||
src = getenv("PLATFORMIO_CI_SRC", "").split(":")
|
||||
if not src:
|
||||
raise click.BadParameter("Missing argument 'src'")
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
from email.utils import parsedate_tz
|
||||
from math import ceil
|
||||
from os import environ
|
||||
from os.path import getsize, join
|
||||
from time import mktime
|
||||
|
||||
@ -50,7 +49,7 @@ class FileDownloader(object):
|
||||
f = open(self._destination, "wb")
|
||||
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
|
||||
|
||||
if environ.get("CI") == "true":
|
||||
if util.is_ci():
|
||||
click.echo("Downloading...")
|
||||
for _ in range(0, chunks):
|
||||
f.write(next(itercontent))
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from os import chmod, environ
|
||||
from os import chmod
|
||||
from os.path import join, splitext
|
||||
from tarfile import open as tarfile_open
|
||||
from time import mktime
|
||||
@ -9,8 +9,8 @@ from zipfile import ZipFile
|
||||
|
||||
import click
|
||||
|
||||
from platformio import util
|
||||
from platformio.exception import UnsupportedArchiveType
|
||||
from platformio.util import change_filemtime
|
||||
|
||||
|
||||
class ArchiveBase(object):
|
||||
@ -51,7 +51,7 @@ class ZIPArchive(ArchiveBase):
|
||||
|
||||
@staticmethod
|
||||
def preserve_mtime(item, dest_dir):
|
||||
change_filemtime(
|
||||
util.change_filemtime(
|
||||
join(dest_dir, item.filename),
|
||||
mktime(list(item.date_time) + [0]*3)
|
||||
)
|
||||
@ -81,7 +81,7 @@ class FileUnpacker(object):
|
||||
raise UnsupportedArchiveType(archpath)
|
||||
|
||||
def start(self):
|
||||
if environ.get("CI") == "true":
|
||||
if util.is_ci():
|
||||
click.echo("Unpacking...")
|
||||
for item in self._unpacker.get_items():
|
||||
self._unpacker.extract_item(item, self._dest_dir)
|
||||
|
@ -175,6 +175,10 @@ def change_filemtime(path, time):
|
||||
os.utime(path, (time, time))
|
||||
|
||||
|
||||
def is_ci():
|
||||
return os.getenv("CI", "").lower() == "true"
|
||||
|
||||
|
||||
def exec_command(*args, **kwargs):
|
||||
result = {
|
||||
"out": None,
|
||||
@ -248,7 +252,7 @@ def get_logicaldisks():
|
||||
def get_request_defheaders():
|
||||
return {"User-Agent": "PlatformIO/%s CI/%d %s" % (
|
||||
__version__,
|
||||
1 if os.environ.get("CI", "").lower() == "true" else 0,
|
||||
1 if is_ci() else 0,
|
||||
requests.utils.default_user_agent()
|
||||
)}
|
||||
|
||||
|
Reference in New Issue
Block a user