PyXMake Developer Guide: src/PyXMake/VTL/__install__.py Source File

| PyXMake Developer Guide 1.0 PyXMake

Loading...
Searching...
No Matches
__install__.py
1# -*- coding: utf-8 -*-
2# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3# % Installation %
4# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5"""
6Set up environment for installation procedure of all minimum working example scripts
7for PyXMake
8
9@note: PyXMake environment file.
10Created on 26.03.2021
11
12@version: 1.0
13----------------------------------------------------------------------------------------------
14@requires:
15 -
16
17@change:
18 -
19
20@author: garb_ma [DLR-FA,STM Braunschweig]
21----------------------------------------------------------------------------------------------
22"""
23
24## @package PyXMake.VTL.__install__
25# Install minimum working example scripts from PyXMake
26## @author
27# Marc Garbade
28## @date
29# 26.03.2021
30## @par Notes/Changes
31# - Added documentation // mg 26.03.2021
32
33import os, sys
34import glob
35
36 def main():
37 """
38 Main function to execute the script.
39 """
40 def GetFromSVN():
41 """
42 Install scripts from predefined SVN repository.
43 """
44 __package = "examples"
45 __delimn = " "; __url_delimn = "/"
46 __scripts_package = os.path.join(os.path.dirname(os.path.abspath(__file__)),__package)
47 if not os.path.exists(__scripts_package) or not os.listdir(__scripts_package):
48 print("==================================")
49 print("Installing minimum working examples")
50 print("==================================")
51 __svn_repo = __url_delimn.join(["https:","","svn.dlr.de","STM-Routines","Tools_Utilities","PyXMake","trunk","minExample"])
52 os.system(__delimn.join(['svn', '--non-interactive', 'checkout', '--depth files', __svn_repo,__scripts_package]))
53 # Return success
54 return 0
55
56 def GetFromGIT():
57 """
58 Install scripts from predefined GIT repository.
59 """
60 # Avoid conflicting imports
61 try: sys.path.remove(os.path.dirname(os.path.abspath(__file__)))
62 except: import git #@UnusedImport
63 else:
64 import git #@Reimport
65 sys.path.insert(0,os.path.abspath(__file__))
66 finally: pass
67 # Procedure
68 __package = "examples"
69 __delimn = " "; __url_delimn = "/"
70 __scripts_package = os.path.join(os.path.dirname(os.path.abspath(__file__)),__package)
71 # Fetch script directory
72 if not os.path.exists(__scripts_package) or not os.listdir(__scripts_package):
73 print("==================================")
74 print("Installing minimum working examples")
75 print("==================================")
76 __git_server_access = "gitlab.dlr.de"
77 __git_repo = __url_delimn.join(["https:","",__git_server_access,"fa_sw","stmlab","PyXMake"+".git"])
78 git.Repo.clone_from(__git_repo, __scripts_package, single_branch=True, b="pyx_examples") #@UndefinedVariable
79 # Additionally fetch documentation if not existing
80 __doc_package = os.path.join(os.path.dirname(__scripts_package),"doc")
81 if not os.path.exists(__doc_package) or not os.listdir(__doc_package):
82 print("==================================")
83 print("Installing documentation")
84 print("==================================")
85 __git_server_access = "gitlab.dlr.de"
86 __git_repo = __url_delimn.join(["https:","",__git_server_access,"fa_sw","stmlab","PyXMake"+".git"])
87 git.Repo.clone_from(__git_repo, __doc_package, single_branch=True, b="pyx_docs") #@UndefinedVariable
88 # Return success
89 return 0
90
91 ## Get examples files from GIT or SVN (GIT priority)
92 try: GetFromGIT()
93 except: GetFromSVN()
94
95 currentdir = os.getcwd()
96 os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),"examples"))
97 symlinks = [(os.path.join(os.path.dirname(os.path.abspath(__file__)),"examples",x),
98 os.path.join(os.path.dirname(os.path.abspath(__file__)),x.replace("pyx_","")))
99 for x in glob.glob('pyx_*.py')]; os.chdir(currentdir)
100
101 # Create a hard link on the current system (this privilege is always active)
102 for pair in symlinks:
103 if not os.path.exists(pair[-1]): os.link(pair[0],pair[1])
104
105 # Return success
106 return 0
107
108if __name__ == "__main__":
109 main(); sys.exit()
PyXMake.VTL.__install__.main
main()
Definition __install__.py:36