Skip to content

Commit

Permalink
Move Exception declarations into own file (#1667)
Browse files Browse the repository at this point in the history
This is a refactor; it adds no new functionality, but is part of a larger effort to move code out of (too large) `buildozer/__init__.py`.

Also made any import lists that were touched pep8-compliant in sort order.
  • Loading branch information
Julian-O authored Aug 23, 2023
1 parent c529b10 commit a1a141c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 42 deletions.
17 changes: 1 addition & 16 deletions buildozer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# on windows, no fcntl
fcntl = None

from buildozer.exceptions import BuildozerCommandException
from buildozer.jsonstore import JsonStore
from buildozer.logger import Logger
from buildozer.specparser import SpecParser
Expand All @@ -50,22 +51,6 @@ class ChromeDownloader(FancyURLopener):
urlretrieve = ChromeDownloader().retrieve


class BuildozerException(Exception):
'''
Exception raised for general situations buildozer cannot process.
'''
pass


class BuildozerCommandException(BuildozerException):
'''
Exception raised when an external command failed.
See: `Buildozer.cmd()`.
'''
pass


class Buildozer:

standard_cmds = ('distclean', 'update', 'debug', 'release',
Expand Down
4 changes: 3 additions & 1 deletion buildozer/scripts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
'''

import sys
from buildozer import Buildozer, BuildozerCommandException, BuildozerException

from buildozer import Buildozer
from buildozer.exceptions import BuildozerCommandException, BuildozerException
from buildozer.logger import Logger


Expand Down
16 changes: 9 additions & 7 deletions buildozer/scripts/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,28 @@

__all__ = ["BuildozerRemote"]

from configparser import ConfigParser
from os import makedirs, walk, getcwd
from os.path import join, expanduser, realpath, exists, splitext
import socket
from select import select
import sys
from buildozer import (
Buildozer, BuildozerCommandException, BuildozerException, __version__)
from buildozer.logger import Logger
from sys import stdout, stdin, exit
from select import select
from os.path import join, expanduser, realpath, exists, splitext
from os import makedirs, walk, getcwd
from configparser import ConfigParser
try:
import termios
has_termios = True
except ImportError:
has_termios = False

try:
import paramiko
except ImportError:
print('Paramiko missing: pip install paramiko')

from buildozer import Buildozer, __version__
from buildozer.exceptions import BuildozerCommandException, BuildozerException
from buildozer.logger import Logger


class BuildozerRemote(Buildozer):
def run_command(self, args):
Expand Down
24 changes: 13 additions & 11 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@
# doesn't support any newer NDK.
DEFAULT_ANDROID_NDK_VERSION = '17c'

import traceback
import io
import re
import ast
from sys import platform, executable
from buildozer import BuildozerException
from buildozer.logger import USE_COLOR
from buildozer.target import Target
from glob import glob
import io
from os import environ
from os.path import exists, join, realpath, expanduser, basename, relpath
from platform import architecture
from shutil import copyfile, rmtree, which
import re
import shlex
import pexpect
from glob import glob
from shutil import copyfile, rmtree, which
from sys import platform, executable
from time import sleep
import traceback

from buildozer.libs.version import parse
from distutils.version import LooseVersion
import pexpect

from buildozer.exceptions import BuildozerException
from buildozer.logger import USE_COLOR
from buildozer.target import Target
from buildozer.libs.version import parse


# buildozer.spec tokens that used to exist but are now ignored
DEPRECATED_TOKENS = (('app', 'android.sdk'), )
Expand Down
10 changes: 6 additions & 4 deletions buildozer/targets/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
iOS target, based on kivy-ios project
'''

import sys

from getpass import getpass
from os.path import join, basename, expanduser, realpath
import plistlib
from buildozer import BuildozerCommandException
import sys

from buildozer.exceptions import BuildozerCommandException
from buildozer.target import Target, no_config
from os.path import join, basename, expanduser, realpath
from getpass import getpass


PHP_TEMPLATE = '''
Expand Down
5 changes: 3 additions & 2 deletions tests/scripts/test_client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sys
import unittest
from buildozer import BuildozerCommandException
from buildozer.scripts import client
from unittest import mock

from buildozer.exceptions import BuildozerCommandException
from buildozer.scripts import client


class TestClient(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion tests/targets/test_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from buildozer import BuildozerCommandException
from buildozer.exceptions import BuildozerCommandException
from buildozer.targets.ios import TargetIos
from tests.targets.utils import (
init_buildozer,
Expand Down

0 comments on commit a1a141c

Please sign in to comment.