forked from adamrehn/ue4-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
98 lines (85 loc) · 3.37 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from .infrastructure import DarwinUtils, DockerUtils, Logger, PrettyPrinting, WindowsUtils
from .build import build
from .clean import clean
from .diagnostics_cmd import diagnostics
from .export import export
from .info import info
from .setup_cmd import setup
from .test import test
from .version_cmd import version
import logging, os, platform, sys
def _exitWithError(err):
Logger().error(err)
sys.exit(1)
def main():
# Configure verbose logging if the user requested it
# (NOTE: in a future version of ue4-docker the `Logger` class will be properly integrated with standard logging)
if '-v' in sys.argv or '--verbose' in sys.argv:
sys.argv = list([arg for arg in sys.argv if arg not in ['-v', '--verbose']])
logging.getLogger().setLevel(logging.DEBUG)
# Verify that Docker is installed
if DockerUtils.installed() == False:
_exitWithError('Error: could not detect Docker daemon version. Please ensure Docker is installed.')
# Under Windows, verify that the host is a supported version
if platform.system() == 'Windows' and WindowsUtils.isSupportedWindowsVersion() == False:
_exitWithError('Error: the detected version of Windows ({}) is not supported. Windows 10 / Windows Server version 1607 or newer is required.'.format(platform.win32_ver()[1]))
# Under macOS, verify that the host is a supported version
if platform.system() == 'Darwin' and DarwinUtils.isSupportedMacOsVersion() == False:
_exitWithError('Error: the detected version of macOS ({}) is not supported. macOS {} or newer is required.'.format(DarwinUtils.getMacOsVersion(), DarwinUtils.minimumRequiredVersion()))
# Our supported commands
COMMANDS = {
'build': {
'function': build,
'description': 'Builds container images for a specific version of UE4'
},
'clean': {
'function': clean,
'description': 'Cleans built container images'
},
'diagnostics': {
'function': diagnostics,
'description': 'Runs diagnostics to detect issues with the host system configuration'
},
'export': {
'function': export,
'description': 'Exports components from built container images to the host system'
},
'info': {
'function': info,
'description': 'Displays information about the host system and Docker daemon'
},
'setup': {
'function': setup,
'description': 'Automatically configures the host system where possible'
},
'test': {
'function': test,
'description': 'Runs tests to verify the correctness of built container images'
},
'version': {
'function': version,
'description': 'Prints the ue4-docker version number'
}
}
# Truncate argv[0] to just the command name without the full path
sys.argv[0] = os.path.basename(sys.argv[0])
# Determine if a command has been specified
if len(sys.argv) > 1:
# Verify that the specified command is valid
command = sys.argv[1]
if command not in COMMANDS:
print('Error: unrecognised command "{}".'.format(command), file=sys.stderr)
sys.exit(1)
# Invoke the command
sys.argv = [sys.argv[0]] + sys.argv[2:]
COMMANDS[command]['function']()
else:
# Print usage syntax
print('Usage: {} COMMAND [OPTIONS]\n'.format(sys.argv[0]))
print('Windows and Linux containers for Unreal Engine 4\n')
print('Commands:')
PrettyPrinting.printColumns([
(command, COMMANDS[command]['description'])
for command in COMMANDS
])
print('\nRun `{} COMMAND --help` for more information on a command.'.format(sys.argv[0]))