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