1
- # Copyright 2014 ARM Limited
1
+ # Copyright 2014-2015 ARM Limited
2
2
#
3
3
# Licensed under the Apache License, Version 2.0
4
4
# See LICENSE file for details.
10
10
# colorama, BSD 3-Clause license, color terminal output, pip install colorama
11
11
import colorama
12
12
13
- # Target, , represents an installed target, internal
14
- from .lib import target
15
13
# fsutils, , misc filesystem utils, internal
16
14
from .lib import fsutils
15
+ # validate, , validate things, internal
16
+ from .lib import validate
17
17
# folders, , get places to install things, internal
18
18
from .lib import folders
19
19
@@ -26,20 +26,25 @@ def addOptions(parser):
26
26
27
27
def execCommand (args , following_args ):
28
28
if args .target :
29
+ c = validate .currentDirectoryModule ()
30
+ if not c :
31
+ return 1
32
+ err = validate .targetNameValidationError (args .target )
33
+ if err :
34
+ logging .error (err )
35
+ return 1
29
36
fsutils .mkDirP (os .path .join (os .getcwd (), 'yotta_targets' ))
30
37
src = os .path .join (folders .globalTargetInstallDirectory (), args .target )
31
38
dst = os .path .join (os .getcwd (), 'yotta_targets' , args .target )
32
39
# if the target is already installed, rm it
33
40
fsutils .rmRf (dst )
34
41
else :
35
- c = target .Target (os .getcwd ())
36
- if not c :
37
- logging .debug (str (c .error ))
38
- logging .error ('The current directory does not contain a valid target.' )
42
+ t = validate .currentDirectoryTarget ()
43
+ if not t :
39
44
return 1
40
45
fsutils .mkDirP (folders .globalTargetInstallDirectory ())
41
46
src = os .getcwd ()
42
- dst = os .path .join (folders .globalTargetInstallDirectory (), c .getName ())
47
+ dst = os .path .join (folders .globalTargetInstallDirectory (), t .getName ())
43
48
44
49
if args .target :
45
50
realsrc = fsutils .realpath (src )
0 commit comments