|
8 | 8 | import logging
|
9 | 9 | import tempfile
|
10 | 10 | import re
|
| 11 | +import platform |
11 | 12 |
|
12 | 13 | logging.basicConfig(level=logging.ERROR) # DEBUG => print ALL msgs
|
13 | 14 |
|
14 | 15 | modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
|
15 | 16 |
|
| 17 | +def get_path_to_1c(): |
| 18 | + ''' |
| 19 | + get path to 1c binary. |
| 20 | + fist env, "PATH1C" |
| 21 | + two env "PROGRAMFILES" on windows |
| 22 | + three /opt/1c - only linux |
| 23 | + |
| 24 | + ''' |
| 25 | + |
| 26 | + cmd = os.getenv("PATH1C") |
| 27 | + if not cmd is None: |
| 28 | + return os.getenv("PATH1C") |
| 29 | + |
| 30 | + if platform.system() == "Darwin": |
| 31 | + raise Exception("MacOS not run 1C") |
| 32 | + elif platform.system() == "Windows": |
| 33 | + program_files = os.getenv("PROGRAMFILES(X86)") |
| 34 | + if program_files is None: |
| 35 | + #FIXME: проверить архетиктуру. |
| 36 | + program_files = os.getenv("PROGRAMFILES") |
| 37 | + if program_files is None: |
| 38 | + raise Exeption("path to Program files not found"); |
| 39 | + cmd = os.path.join(program_files, "1cv8") |
| 40 | + maxversion = max(list(filter((lambda x: '8.' in x), os.listdir(cmd)))) |
| 41 | + if maxversion is None: |
| 42 | + raise Exception("not found verion dirs") |
| 43 | + cmd = os.path.join(cmd, maxversion + os.path.sep + "bin"+os.path.sep+"1cv8.exe") |
| 44 | + |
| 45 | + if not os.path.isfile(cmd): |
| 46 | + raise Exception("file not found %s" %(cmd)) |
| 47 | + |
| 48 | + else: |
| 49 | + cmd = subprocess.Popen(["which", "1cv8"], stdout=PIPE).communicate()[0].strip() |
| 50 | + |
| 51 | + return cmd |
16 | 52 |
|
17 | 53 | def get_list_of_comitted_files():
|
18 | 54 | """
|
@@ -61,8 +97,9 @@ def decompile():
|
61 | 97 |
|
62 | 98 | dirsource = os.path.abspath(os.path.join(os.path.curdir, "src"))
|
63 | 99 | curabsdirpath = os.path.abspath(os.path.curdir)
|
64 |
| - pathbin1c = "C:\\Program Files\\1cv82\8.2.17.153\\bin\\1cv8.exe" |
65 |
| - pathbin1c = "c:\\Program Files (x86)\\1cv8\\8.3.4.304\\bin\\1cv8.exe" |
| 100 | + #pathbin1c = "C:\\Program Files\\1cv82\8.2.17.153\\bin\\1cv8.exe" |
| 101 | + #pathbin1c = "c:\\Program Files (x86)\\1cv8\\8.3.4.304\\bin\\1cv8.exe" |
| 102 | + pathbin1c = get_path_to_1c() |
66 | 103 |
|
67 | 104 | for filename in dataprocessor_files:
|
68 | 105 | print("file %s" % filename)
|
|
0 commit comments