chore: fix python lint warnings (#14638)
* chore: fix lint warnings * chore: another try at python import errors Looks like the problem is that dbus_mock.py is running as a script but living in the `lib/` directory where it's part of a module. Moving it up into the `script/` directory seems to solve the issue.
This commit is contained in:
		
					parent
					
						
							
								6d01952e66
							
						
					
				
			
			
				commit
				
					
						a45ded5508
					
				
			
		
					 15 changed files with 111 additions and 74 deletions
				
			
		| 
						 | 
					@ -5,7 +5,7 @@ import os
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import lib.git as git
 | 
					from lib import git
 | 
				
			||||||
from lib.patches import PatchesConfig
 | 
					from lib.patches import PatchesConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,7 @@ def main():
 | 
				
			||||||
  else:
 | 
					  else:
 | 
				
			||||||
    raise Exception("Invalid current version: " + curr_version)
 | 
					    raise Exception("Invalid current version: " + curr_version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if args.new_version == None and args.bump == None and args.stable == False:
 | 
					  if args.new_version is None and args.bump is None and not args.stable:
 | 
				
			||||||
    parser.print_help()
 | 
					    parser.print_help()
 | 
				
			||||||
    return 1
 | 
					    return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,29 +57,28 @@ def getBrokenLinks(filepath):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for link in links:
 | 
					  for link in links:
 | 
				
			||||||
    sections = link.split('#')
 | 
					    sections = link.split('#')
 | 
				
			||||||
    if len(sections) > 1:
 | 
					    if len(sections) < 2:
 | 
				
			||||||
      if str(link).startswith('#'):
 | 
					 | 
				
			||||||
        if not checkSections(sections, lines):
 | 
					 | 
				
			||||||
          brokenLinks.append(link)
 | 
					 | 
				
			||||||
      else:
 | 
					 | 
				
			||||||
        tempFile = os.path.join(currentDir, sections[0])
 | 
					 | 
				
			||||||
        if os.path.isfile(tempFile):
 | 
					 | 
				
			||||||
          try:
 | 
					 | 
				
			||||||
            newFile = open(tempFile, 'r')
 | 
					 | 
				
			||||||
            newLines = newFile.readlines()
 | 
					 | 
				
			||||||
          except KeyboardInterrupt:
 | 
					 | 
				
			||||||
            print('Keyboard interruption whle parsing. Please try again.')
 | 
					 | 
				
			||||||
          finally:
 | 
					 | 
				
			||||||
            newFile.close()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          if not checkSections(sections, newLines):
 | 
					 | 
				
			||||||
            brokenLinks.append(link)
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
          brokenLinks.append(link)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
      if not os.path.isfile(os.path.join(currentDir, link)):
 | 
					      if not os.path.isfile(os.path.join(currentDir, link)):
 | 
				
			||||||
        brokenLinks.append(link)
 | 
					        brokenLinks.append(link)
 | 
				
			||||||
 | 
					    elif str(link).startswith('#'):
 | 
				
			||||||
 | 
					      if not checkSections(sections, lines):
 | 
				
			||||||
 | 
					        brokenLinks.append(link)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					      tempFile = os.path.join(currentDir, sections[0])
 | 
				
			||||||
 | 
					      if os.path.isfile(tempFile):
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					          newFile = open(tempFile, 'r')
 | 
				
			||||||
 | 
					          newLines = newFile.readlines()
 | 
				
			||||||
 | 
					        except KeyboardInterrupt:
 | 
				
			||||||
 | 
					          print('Keyboard interruption whle parsing. Please try again.')
 | 
				
			||||||
 | 
					        finally:
 | 
				
			||||||
 | 
					          newFile.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if not checkSections(sections, newLines):
 | 
				
			||||||
 | 
					          brokenLinks.append(link)
 | 
				
			||||||
 | 
					      else:
 | 
				
			||||||
 | 
					        brokenLinks.append(link)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  print_errors(filepath, brokenLinks)
 | 
					  print_errors(filepath, brokenLinks)
 | 
				
			||||||
  return len(brokenLinks)
 | 
					  return len(brokenLinks)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,28 +1,31 @@
 | 
				
			||||||
from config import is_verbose_mode
 | 
					#!/usr/bin/env python
 | 
				
			||||||
from dbusmock import DBusTestCase
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import atexit
 | 
					import atexit
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					import subprocess
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from dbusmock import DBusTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from lib.config import is_verbose_mode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def stop():
 | 
					def stop():
 | 
				
			||||||
    DBusTestCase.stop_dbus(DBusTestCase.system_bus_pid)
 | 
					    DBusTestCase.stop_dbus(DBusTestCase.system_bus_pid)
 | 
				
			||||||
    DBusTestCase.stop_dbus(DBusTestCase.session_bus_pid)
 | 
					    DBusTestCase.stop_dbus(DBusTestCase.session_bus_pid)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def start():
 | 
					def start():
 | 
				
			||||||
    dbusmock_log = sys.stdout if is_verbose_mode() else open(os.devnull, 'w')
 | 
					    log = sys.stdout if is_verbose_mode() else open(os.devnull, 'w')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DBusTestCase.start_system_bus()
 | 
					    DBusTestCase.start_system_bus()
 | 
				
			||||||
    DBusTestCase.spawn_server_template('logind', None, dbusmock_log)
 | 
					    DBusTestCase.spawn_server_template('logind', None, log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DBusTestCase.start_session_bus()
 | 
					    DBusTestCase.start_session_bus()
 | 
				
			||||||
    DBusTestCase.spawn_server_template('notification_daemon', None, dbusmock_log)
 | 
					    DBusTestCase.spawn_server_template('notification_daemon', None, log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    import subprocess
 | 
					 | 
				
			||||||
    start()
 | 
					    start()
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
 | 
					        print(sys.argv)
 | 
				
			||||||
        subprocess.check_call(sys.argv[1:])
 | 
					        subprocess.check_call(sys.argv[1:])
 | 
				
			||||||
    finally:
 | 
					    finally:
 | 
				
			||||||
        stop()
 | 
					        stop()
 | 
				
			||||||
| 
						 | 
					@ -6,10 +6,13 @@ import platform
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# URL to the mips64el sysroot image.
 | 
					# URL to the mips64el sysroot image.
 | 
				
			||||||
MIPS64EL_SYSROOT_URL = 'https://github.com/electron/debian-sysroot-image-creator/releases/download/v0.5.0/debian_jessie_mips64-sysroot.tar.bz2'
 | 
					MIPS64EL_SYSROOT_URL = 'https://github.com/electron' \
 | 
				
			||||||
 | 
					                     + '/debian-sysroot-image-creator/releases/download' \
 | 
				
			||||||
 | 
					                     + '/v0.5.0/debian_jessie_mips64-sysroot.tar.bz2'
 | 
				
			||||||
# URL to the mips64el toolchain.
 | 
					# URL to the mips64el toolchain.
 | 
				
			||||||
MIPS64EL_GCC = 'gcc-4.8.3-d197-n64-loongson'
 | 
					MIPS64EL_GCC = 'gcc-4.8.3-d197-n64-loongson'
 | 
				
			||||||
MIPS64EL_GCC_URL = 'http://ftp.loongnix.org/toolchain/gcc/release/' + MIPS64EL_GCC + '.tar.gz'
 | 
					MIPS64EL_GCC_URL = 'http://ftp.loongnix.org/toolchain/gcc/release/' \
 | 
				
			||||||
 | 
					                 + MIPS64EL_GCC + '.tar.gz'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
 | 
					BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
 | 
				
			||||||
    'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
 | 
					    'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
 | 
				
			||||||
| 
						 | 
					@ -89,7 +92,8 @@ def get_zip_name(name, version, suffix=''):
 | 
				
			||||||
def build_env():
 | 
					def build_env():
 | 
				
			||||||
  env = os.environ.copy()
 | 
					  env = os.environ.copy()
 | 
				
			||||||
  if get_target_arch() == "mips64el":
 | 
					  if get_target_arch() == "mips64el":
 | 
				
			||||||
    SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
 | 
					    SOURCE_ROOT = os.path.abspath(os.path.dirname(
 | 
				
			||||||
 | 
					                    os.path.dirname(os.path.dirname(__file__))))
 | 
				
			||||||
    VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
 | 
					    VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
 | 
				
			||||||
    gcc_dir = os.path.join(VENDOR_DIR, MIPS64EL_GCC)
 | 
					    gcc_dir = os.path.join(VENDOR_DIR, MIPS64EL_GCC)
 | 
				
			||||||
    ldlib_dirs = [
 | 
					    ldlib_dirs = [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,9 +16,10 @@ def validate_pair(ob):
 | 
				
			||||||
    return True
 | 
					    return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def consume(iter):
 | 
					def consume(iterator):
 | 
				
			||||||
  try:
 | 
					  try:
 | 
				
			||||||
    while True: next(iter)
 | 
					    while True:
 | 
				
			||||||
 | 
					      next(iterator)
 | 
				
			||||||
  except StopIteration:
 | 
					  except StopIteration:
 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,11 +37,11 @@ def get_environment_from_batch_command(env_cmd, initial=None):
 | 
				
			||||||
  if not isinstance(env_cmd, (list, tuple)):
 | 
					  if not isinstance(env_cmd, (list, tuple)):
 | 
				
			||||||
    env_cmd = [env_cmd]
 | 
					    env_cmd = [env_cmd]
 | 
				
			||||||
  # Construct the command that will alter the environment.
 | 
					  # Construct the command that will alter the environment.
 | 
				
			||||||
  env_cmd = subprocess.list2cmdline(env_cmd)
 | 
					  cmd = subprocess.list2cmdline(env_cmd)
 | 
				
			||||||
  # Create a tag so we can tell in the output when the proc is done.
 | 
					  # Create a tag so we can tell in the output when the proc is done.
 | 
				
			||||||
  tag = 'END OF BATCH COMMAND'
 | 
					  tag = 'END OF BATCH COMMAND'
 | 
				
			||||||
  # Construct a cmd.exe command to do accomplish this.
 | 
					  # Construct a cmd.exe command to do accomplish this.
 | 
				
			||||||
  cmd = 'cmd.exe /s /c "{env_cmd} && echo "{tag}" && set"'.format(**vars())
 | 
					  cmd = 'cmd.exe /s /c "{cmd} && echo "{tag}" && set"'.format(**locals())
 | 
				
			||||||
  # Launch the process.
 | 
					  # Launch the process.
 | 
				
			||||||
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial)
 | 
					  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial)
 | 
				
			||||||
  # Parse the output sent to stdout.
 | 
					  # Parse the output sent to stdout.
 | 
				
			||||||
| 
						 | 
					@ -63,10 +64,11 @@ def get_vs_location(vs_version):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Returns the location of the VS building environment.
 | 
					    Returns the location of the VS building environment.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    The vs_version can be strings like "[15.0,16.0)", meaning 2017, but not the next version.
 | 
					    The vs_version can be strings like "[15.0,16.0)", meaning 2017,
 | 
				
			||||||
 | 
					    but not the next version.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # vswhere can't handle spaces, like "[15.0, 16.0)" should become "[15.0,16.0)"
 | 
					    # vswhere can't handle spaces. "[15.0, 16.0)" should become "[15.0,16.0)"
 | 
				
			||||||
    vs_version = vs_version.replace(" ", "")
 | 
					    vs_version = vs_version.replace(" ", "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    program_files = os.environ.get('ProgramFiles(x86)')
 | 
					    program_files = os.environ.get('ProgramFiles(x86)')
 | 
				
			||||||
| 
						 | 
					@ -86,10 +88,10 @@ def get_vs_env(vs_version, arch):
 | 
				
			||||||
  """
 | 
					  """
 | 
				
			||||||
  Returns the env object for VS building environment.
 | 
					  Returns the env object for VS building environment.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  vs_version is the version of Visual Studio to use.  See get_vs_location for
 | 
					  vs_version is the version of Visual Studio to use.
 | 
				
			||||||
  more details.
 | 
					  See get_vs_location for more details.
 | 
				
			||||||
  The arch has to be one of "x86", "amd64", "arm", "x86_amd64", "x86_arm", "amd64_x86",
 | 
					  The arch must be one of "x86", "amd64", "arm", "x86_amd64", "x86_arm",
 | 
				
			||||||
  "amd64_arm", i.e. the args passed to vcvarsall.bat.
 | 
					  "amd64_x86", "amd64_arm", i.e. the args passed to vcvarsall.bat.
 | 
				
			||||||
  """
 | 
					  """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  location = get_vs_location(vs_version)
 | 
					  location = get_vs_location(vs_version)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,15 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""Git helper functions.
 | 
					"""Git helper functions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Everything in here should be project agnostic, shouldn't rely on project's structure,
 | 
					Everything here should be project agnostic: it shouldn't rely on project's
 | 
				
			||||||
and make any assumptions about the passed arguments or calls outcomes.
 | 
					structure, or make assumptions about the passed arguments or calls' outcomes.
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from util import scoped_cwd
 | 
					from lib.util import scoped_cwd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def is_repo_root(path):
 | 
					def is_repo_root(path):
 | 
				
			||||||
| 
						 | 
					@ -40,7 +42,7 @@ def get_repo_root(path):
 | 
				
			||||||
  return get_repo_root(parent_path)
 | 
					  return get_repo_root(parent_path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def apply(repo, patch_path, directory=None, index=False, reverse=False):
 | 
					def apply_patch(repo, patch_path, directory=None, index=False, reverse=False):
 | 
				
			||||||
  args = ['git', 'apply',
 | 
					  args = ['git', 'apply',
 | 
				
			||||||
          '--ignore-space-change',
 | 
					          '--ignore-space-change',
 | 
				
			||||||
          '--ignore-whitespace',
 | 
					          '--ignore-whitespace',
 | 
				
			||||||
| 
						 | 
					@ -64,7 +66,7 @@ def get_patch(repo, commit_hash):
 | 
				
			||||||
  args = ['git', 'diff-tree',
 | 
					  args = ['git', 'diff-tree',
 | 
				
			||||||
          '-p',
 | 
					          '-p',
 | 
				
			||||||
          commit_hash,
 | 
					          commit_hash,
 | 
				
			||||||
          '--'  # Explicitly tell Git that `commit_hash` is a revision, not a path.
 | 
					          '--'  # Explicitly tell Git `commit_hash` is a revision, not a path.
 | 
				
			||||||
          ]
 | 
					          ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  with scoped_cwd(repo):
 | 
					  with scoped_cwd(repo):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from util import scoped_cwd
 | 
					from lib.util import scoped_cwd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class GNProject:
 | 
					class GNProject:
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,8 @@ class GNProject:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def run(self, command_name, command_args):
 | 
					  def run(self, command_name, command_args):
 | 
				
			||||||
    with scoped_cwd(self.out_dir):
 | 
					    with scoped_cwd(self.out_dir):
 | 
				
			||||||
      complete_args = [self._get_executable_name(), command_name, '.'] + command_args
 | 
					      complete_args = [self._get_executable_name(), command_name, '.'] + \
 | 
				
			||||||
 | 
					                      command_args
 | 
				
			||||||
      return subprocess.check_output(complete_args)
 | 
					      return subprocess.check_output(complete_args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def args(self):
 | 
					  def args(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,20 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import git
 | 
					from lib import git
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
 | 
					SOURCE_ROOT = os.path.abspath(os.path.dirname(
 | 
				
			||||||
 | 
					                os.path.dirname(os.path.dirname(__file__))))
 | 
				
			||||||
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
 | 
					VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
 | 
				
			||||||
PYYAML_LIB_DIR = os.path.join(VENDOR_DIR, 'pyyaml', 'lib')
 | 
					PYYAML_LIB_DIR = os.path.join(VENDOR_DIR, 'pyyaml', 'lib')
 | 
				
			||||||
sys.path.append(PYYAML_LIB_DIR)
 | 
					sys.path.append(PYYAML_LIB_DIR)
 | 
				
			||||||
import yaml
 | 
					import yaml  #pylint: disable=wrong-import-position,wrong-import-order
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Patch:
 | 
					class Patch:
 | 
				
			||||||
  def __init__(self, file_path, repo_path, paths_prefix=None, author='Anonymous <anonymous@electronjs.org>', description=None):
 | 
					  def __init__(self, file_path, repo_path, paths_prefix=None,
 | 
				
			||||||
 | 
					               author='Anonymous <anonymous@electronjs.org>', description=None):
 | 
				
			||||||
    self.author = author
 | 
					    self.author = author
 | 
				
			||||||
    self.description = description
 | 
					    self.description = description
 | 
				
			||||||
    self.file_path = file_path
 | 
					    self.file_path = file_path
 | 
				
			||||||
| 
						 | 
					@ -21,14 +24,17 @@ class Patch:
 | 
				
			||||||
  def apply(self, reverse=False, commit=False, index=False):
 | 
					  def apply(self, reverse=False, commit=False, index=False):
 | 
				
			||||||
    # Add the change to index only if we're going to commit it later.
 | 
					    # Add the change to index only if we're going to commit it later.
 | 
				
			||||||
    add_to_index = index or commit
 | 
					    add_to_index = index or commit
 | 
				
			||||||
    patch_applied = git.apply(self.repo_path, self.file_path, directory=self.paths_prefix, index=add_to_index, reverse=reverse)
 | 
					    patch_applied = git.apply_patch(self.repo_path, self.file_path,
 | 
				
			||||||
 | 
					                                    directory=self.paths_prefix,
 | 
				
			||||||
 | 
					                                    index=add_to_index, reverse=reverse)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if not patch_applied:
 | 
					    if not patch_applied:
 | 
				
			||||||
      return False
 | 
					      return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if commit:
 | 
					    if commit:
 | 
				
			||||||
      message = self.__get_commit_message(reverse)
 | 
					      message = self.__get_commit_message(reverse)
 | 
				
			||||||
      patch_committed = git.commit(self.repo_path, author=self.author, message=message)
 | 
					      patch_committed = git.commit(self.repo_path, author=self.author,
 | 
				
			||||||
 | 
					                                   message=message)
 | 
				
			||||||
      return patch_committed
 | 
					      return patch_committed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return True
 | 
					    return True
 | 
				
			||||||
| 
						 | 
					@ -72,7 +78,8 @@ class PatchesList:
 | 
				
			||||||
      # Applying all commits takes about 10 minutes (!) on a fast dev machine.
 | 
					      # Applying all commits takes about 10 minutes (!) on a fast dev machine.
 | 
				
			||||||
      # Instead of it we are going only to add all changes to the index
 | 
					      # Instead of it we are going only to add all changes to the index
 | 
				
			||||||
      # and commit them all at once later.
 | 
					      # and commit them all at once later.
 | 
				
			||||||
      applied_successfully = patch.apply(reverse=reverse, index=commit, commit=False)
 | 
					      applied_successfully = patch.apply(reverse=reverse, index=commit,
 | 
				
			||||||
 | 
					                                         commit=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if not applied_successfully:
 | 
					      if not applied_successfully:
 | 
				
			||||||
        all_patches_applied = False
 | 
					        all_patches_applied = False
 | 
				
			||||||
| 
						 | 
					@ -133,7 +140,8 @@ class PatchesConfig:
 | 
				
			||||||
    if raw_data['description'] is not None:
 | 
					    if raw_data['description'] is not None:
 | 
				
			||||||
      description += '\n\n' + raw_data['description']
 | 
					      description += '\n\n' + raw_data['description']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return Patch(absolute_file_path, repo_path, paths_prefix=paths_prefix, author=author, description=description)
 | 
					    return Patch(absolute_file_path, repo_path, paths_prefix=paths_prefix,
 | 
				
			||||||
 | 
					                 author=author, description=description)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def __create_patches_list(self):
 | 
					  def __create_patches_list(self):
 | 
				
			||||||
    config_contents = self.__parse()
 | 
					    config_contents = self.__parse()
 | 
				
			||||||
| 
						 | 
					@ -154,7 +162,8 @@ class PatchesConfig:
 | 
				
			||||||
    patches_data = config_contents['patches']
 | 
					    patches_data = config_contents['patches']
 | 
				
			||||||
    base_directory = os.path.abspath(os.path.dirname(self.path))
 | 
					    base_directory = os.path.abspath(os.path.dirname(self.path))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    patches = [self.__create_patch(data, base_directory, absolute_repo_path, paths_prefix) for data in patches_data]
 | 
					    patches = [self.__create_patch(data, base_directory, absolute_repo_path,
 | 
				
			||||||
 | 
					                                   paths_prefix) for data in patches_data]
 | 
				
			||||||
    patches_list = PatchesList(repo_path=absolute_repo_path, patches=patches)
 | 
					    patches_list = PatchesList(repo_path=absolute_repo_path, patches=patches)
 | 
				
			||||||
    return patches_list
 | 
					    return patches_list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,8 +17,8 @@ import urllib2
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import zipfile
 | 
					import zipfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from config import is_verbose_mode, PLATFORM
 | 
					from lib.config import is_verbose_mode, PLATFORM
 | 
				
			||||||
from env_util import get_vs_env
 | 
					from lib.env_util import get_vs_env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BOTO_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor',
 | 
					BOTO_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor',
 | 
				
			||||||
                                        'boto'))
 | 
					                                        'boto'))
 | 
				
			||||||
| 
						 | 
					@ -142,11 +142,14 @@ def safe_mkdir(path):
 | 
				
			||||||
      raise
 | 
					      raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def execute(argv, env=os.environ, cwd=None):
 | 
					def execute(argv, env=None, cwd=None):
 | 
				
			||||||
 | 
					  if env is None:
 | 
				
			||||||
 | 
					    env = os.environ
 | 
				
			||||||
  if is_verbose_mode():
 | 
					  if is_verbose_mode():
 | 
				
			||||||
    print ' '.join(argv)
 | 
					    print ' '.join(argv)
 | 
				
			||||||
  try:
 | 
					  try:
 | 
				
			||||||
    output = subprocess.check_output(argv, stderr=subprocess.STDOUT, env=env, cwd=cwd)
 | 
					    output = subprocess.check_output(argv, stderr=subprocess.STDOUT,
 | 
				
			||||||
 | 
					                                     env=env, cwd=cwd)
 | 
				
			||||||
    if is_verbose_mode():
 | 
					    if is_verbose_mode():
 | 
				
			||||||
      print output
 | 
					      print output
 | 
				
			||||||
    return output
 | 
					    return output
 | 
				
			||||||
| 
						 | 
					@ -155,7 +158,9 @@ def execute(argv, env=os.environ, cwd=None):
 | 
				
			||||||
    raise e
 | 
					    raise e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def execute_stdout(argv, env=os.environ, cwd=None):
 | 
					def execute_stdout(argv, env=None, cwd=None):
 | 
				
			||||||
 | 
					  if env is None:
 | 
				
			||||||
 | 
					    env = os.environ
 | 
				
			||||||
  if is_verbose_mode():
 | 
					  if is_verbose_mode():
 | 
				
			||||||
    print ' '.join(argv)
 | 
					    print ' '.join(argv)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
| 
						 | 
					@ -210,6 +215,16 @@ def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
 | 
				
			||||||
def add_exec_bit(filename):
 | 
					def add_exec_bit(filename):
 | 
				
			||||||
  os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 | 
					  os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def parse_version(version):
 | 
				
			||||||
 | 
					  if version[0] == 'v':
 | 
				
			||||||
 | 
					    version = version[1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  vs = version.split('.')
 | 
				
			||||||
 | 
					  if len(vs) > 4:
 | 
				
			||||||
 | 
					    return vs[0:4]
 | 
				
			||||||
 | 
					  else:
 | 
				
			||||||
 | 
					    return vs + ['0'] * (4 - len(vs))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def clean_parse_version(v):
 | 
					def clean_parse_version(v):
 | 
				
			||||||
  return parse_version(v.split("-")[0])        
 | 
					  return parse_version(v.split("-")[0])        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -230,7 +245,7 @@ def get_last_major():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_next_nightly(v):
 | 
					def get_next_nightly(v):
 | 
				
			||||||
  pv = clean_parse_version(v)
 | 
					  pv = clean_parse_version(v)
 | 
				
			||||||
  major = pv[0]; minor = pv[1]; patch = pv[2]
 | 
					  (major, minor, patch) = pv[0:3]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (is_stable(v)):
 | 
					  if (is_stable(v)):
 | 
				
			||||||
    patch = str(int(pv[2]) + 1)
 | 
					    patch = str(int(pv[2]) + 1)
 | 
				
			||||||
| 
						 | 
					@ -266,15 +281,16 @@ def get_next_beta(v):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_next_stable_from_pre(v):
 | 
					def get_next_stable_from_pre(v):
 | 
				
			||||||
  pv = clean_parse_version(v)
 | 
					  pv = clean_parse_version(v)
 | 
				
			||||||
  major = pv[0]; minor = pv[1]; patch = pv[2]
 | 
					  (major, minor, patch) = pv[0:3]
 | 
				
			||||||
  return make_version(major, minor, patch)
 | 
					  return make_version(major, minor, patch)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_next_stable_from_stable(v):
 | 
					def get_next_stable_from_stable(v):
 | 
				
			||||||
  pv = clean_parse_version(v)
 | 
					  pv = clean_parse_version(v)
 | 
				
			||||||
  major = pv[0]; minor = pv[1]; patch = pv[2]
 | 
					  (major, minor, patch) = pv[0:3]
 | 
				
			||||||
  return make_version(major, minor, str(int(patch) + 1))
 | 
					  return make_version(major, minor, str(int(patch) + 1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def make_version(major, minor, patch, pre = None):
 | 
					def make_version(major, minor, patch, pre = None):
 | 
				
			||||||
  if pre is None:
 | 
					  if pre is None:
 | 
				
			||||||
    return major + '.' + minor + '.' + patch
 | 
					    return major + '.' + minor + '.' + patch
 | 
				
			||||||
  return major + "." + minor + "." + patch + '-' + pre
 | 
					  return major + "." + minor + "." + patch + '-' + pre
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,12 +62,12 @@ GRAMMAR:
 | 
				
			||||||
       EXPRESSION has Python syntax.
 | 
					       EXPRESSION has Python syntax.
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__author__ = 'wan@google.com (Zhanyong Wan)'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = 'wan@google.com (Zhanyong Wan)'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TOKEN_TABLE = [
 | 
					TOKEN_TABLE = [
 | 
				
			||||||
    (re.compile(r'\$var\s+'), '$var'),
 | 
					    (re.compile(r'\$var\s+'), '$var'),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								script/spec-runner.js
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								script/spec-runner.js
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							| 
						 | 
					@ -1,3 +1,5 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const cp = require('child_process')
 | 
					const cp = require('child_process')
 | 
				
			||||||
const crypto = require('crypto')
 | 
					const crypto = require('crypto')
 | 
				
			||||||
const fs = require('fs')
 | 
					const fs = require('fs')
 | 
				
			||||||
| 
						 | 
					@ -39,7 +41,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
 | 
				
			||||||
  let exe = path.resolve(BASE, utils.getElectronExec())
 | 
					  let exe = path.resolve(BASE, utils.getElectronExec())
 | 
				
			||||||
  const args = process.argv.slice(2)
 | 
					  const args = process.argv.slice(2)
 | 
				
			||||||
  if (process.platform === 'linux') {
 | 
					  if (process.platform === 'linux') {
 | 
				
			||||||
    args.unshift(path.resolve(__dirname, 'lib/dbus_mock.py'), exe)
 | 
					    args.unshift(path.resolve(__dirname, 'dbus_mock.py'), exe)
 | 
				
			||||||
    exe = 'python'
 | 
					    exe = 'python'
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  const child = cp.spawn(exe, args, {
 | 
					  const child = cp.spawn(exe, args, {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,14 @@
 | 
				
			||||||
#!/usr/bin/env python
 | 
					#!/usr/bin/env python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
 | 
					import atexit
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from lib.config import enable_verbose_mode
 | 
					from lib.config import enable_verbose_mode
 | 
				
			||||||
 | 
					import lib.dbus_mock
 | 
				
			||||||
from lib.util import electron_gyp, execute_stdout, rm_rf
 | 
					from lib.util import electron_gyp, execute_stdout, rm_rf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,8 +19,6 @@ if sys.platform == 'linux2':
 | 
				
			||||||
    # while also setting DBUS_SYSTEM_BUS_ADDRESS environment variable, which
 | 
					    # while also setting DBUS_SYSTEM_BUS_ADDRESS environment variable, which
 | 
				
			||||||
    # will be picked up by electron.
 | 
					    # will be picked up by electron.
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        import lib.dbus_mock
 | 
					 | 
				
			||||||
        import atexit
 | 
					 | 
				
			||||||
        lib.dbus_mock.start()
 | 
					        lib.dbus_mock.start()
 | 
				
			||||||
        atexit.register(lib.dbus_mock.stop)
 | 
					        atexit.register(lib.dbus_mock.stop)
 | 
				
			||||||
    except ImportError:
 | 
					    except ImportError:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@ import argparse
 | 
				
			||||||
import hashlib
 | 
					import hashlib
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import tempfile
 | 
					import tempfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from lib.config import s3_config
 | 
					from lib.config import s3_config
 | 
				
			||||||
| 
						 | 
					@ -95,5 +96,4 @@ def copy_files(source_files, output_dir):
 | 
				
			||||||
    shutil.copy2(source_file, output_path)
 | 
					    shutil.copy2(source_file, output_path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
  import sys
 | 
					 | 
				
			||||||
  sys.exit(main())
 | 
					  sys.exit(main())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -210,5 +210,4 @@ def get_release(version):
 | 
				
			||||||
  return release
 | 
					  return release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
  import sys
 | 
					 | 
				
			||||||
  sys.exit(main())
 | 
					  sys.exit(main())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue