Skip to content

Commit 4bc9892

Browse files
author
Shenja Sosna
committed
Merge pull request #6 from pumbaEO/issue#5
Автоматически определяет путь к платформе. Путь может быть указан явно, ...
2 parents 19b8044 + 9076dc3 commit 4bc9892

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

pyv8unpack.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,47 @@
88
import logging
99
import tempfile
1010
import re
11+
import platform
1112

1213
logging.basicConfig(level=logging.ERROR) # DEBUG => print ALL msgs
1314

1415
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
1516

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
1652

1753
def get_list_of_comitted_files():
1854
"""
@@ -61,8 +97,9 @@ def decompile():
6197

6298
dirsource = os.path.abspath(os.path.join(os.path.curdir, "src"))
6399
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()
66103

67104
for filename in dataprocessor_files:
68105
print("file %s" % filename)

0 commit comments

Comments
 (0)