forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix python lint warnings (electron#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.
- Loading branch information
Showing
15 changed files
with
110 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
from config import is_verbose_mode | ||
from dbusmock import DBusTestCase | ||
#!/usr/bin/env python | ||
|
||
import atexit | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
from dbusmock import DBusTestCase | ||
|
||
from lib.config import is_verbose_mode | ||
|
||
def stop(): | ||
DBusTestCase.stop_dbus(DBusTestCase.system_bus_pid) | ||
DBusTestCase.stop_dbus(DBusTestCase.session_bus_pid) | ||
|
||
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.spawn_server_template('logind', None, dbusmock_log) | ||
DBusTestCase.spawn_server_template('logind', None, log) | ||
|
||
DBusTestCase.start_session_bus() | ||
DBusTestCase.spawn_server_template('notification_daemon', None, dbusmock_log) | ||
DBusTestCase.spawn_server_template('notification_daemon', None, log) | ||
|
||
if __name__ == '__main__': | ||
import subprocess | ||
start() | ||
try: | ||
print(sys.argv) | ||
subprocess.check_call(sys.argv[1:]) | ||
finally: | ||
stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
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') | ||
PYYAML_LIB_DIR = os.path.join(VENDOR_DIR, 'pyyaml', 'lib') | ||
sys.path.append(PYYAML_LIB_DIR) | ||
import yaml | ||
|
||
import yaml #pylint: disable=wrong-import-position,wrong-import-order | ||
|
||
class Patch: | ||
def __init__(self, file_path, repo_path, paths_prefix=None, author='Anonymous <[email protected]>', description=None): | ||
def __init__(self, file_path, repo_path, paths_prefix=None, | ||
author='Anonymous <[email protected]>', description=None): | ||
self.author = author | ||
self.description = description | ||
self.file_path = file_path | ||
|
@@ -21,14 +24,17 @@ def __init__(self, file_path, repo_path, paths_prefix=None, author='Anonymous <a | |
def apply(self, reverse=False, commit=False, index=False): | ||
# Add the change to index only if we're going to commit it later. | ||
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: | ||
return False | ||
|
||
if commit: | ||
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 True | ||
|
@@ -72,7 +78,8 @@ def apply(self, reverse=False, stop_on_error=True, commit=False): | |
# 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 | ||
# 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: | ||
all_patches_applied = False | ||
|
@@ -133,7 +140,8 @@ def __create_patch(self, raw_data, base_directory, repo_path, paths_prefix): | |
if raw_data['description'] is not None: | ||
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): | ||
config_contents = self.__parse() | ||
|
@@ -154,7 +162,8 @@ def __create_patches_list(self): | |
patches_data = config_contents['patches'] | ||
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) | ||
return patches_list | ||
|
||
|
Oops, something went wrong.