diff --git a/pyv8unpack.py b/pyv8unpack.py index 1fdd887..7c2eefb 100644 --- a/pyv8unpack.py +++ b/pyv8unpack.py @@ -8,11 +8,47 @@ import logging import tempfile import re +import platform logging.basicConfig(level=logging.ERROR) # DEBUG => print ALL msgs modified = re.compile('^(?:M|A)(\s+)(?P.*)') +def get_path_to_1c(): + ''' + get path to 1c binary. + fist env, "PATH1C" + two env "PROGRAMFILES" on windows + three /opt/1c - only linux + + ''' + + cmd = os.getenv("PATH1C") + if not cmd is None: + return os.getenv("PATH1C") + + if platform.system() == "Darwin": + raise Exception("MacOS not run 1C") + elif platform.system() == "Windows": + program_files = os.getenv("PROGRAMFILES(X86)") + if program_files is None: + #FIXME: проверить архетиктуру. + program_files = os.getenv("PROGRAMFILES") + if program_files is None: + raise Exeption("path to Program files not found"); + cmd = os.path.join(program_files, "1cv8") + maxversion = max(list(filter((lambda x: '8.' in x), os.listdir(cmd)))) + if maxversion is None: + raise Exception("not found verion dirs") + cmd = os.path.join(cmd, maxversion + os.path.sep + "bin"+os.path.sep+"1cv8.exe") + + if not os.path.isfile(cmd): + raise Exception("file not found %s" %(cmd)) + + else: + cmd = subprocess.Popen(["which", "1cv8"], stdout=PIPE).communicate()[0].strip() + + return cmd def get_list_of_comitted_files(): """ @@ -61,8 +97,9 @@ def decompile(): dirsource = os.path.abspath(os.path.join(os.path.curdir, "src")) curabsdirpath = os.path.abspath(os.path.curdir) - pathbin1c = "C:\\Program Files\\1cv82\8.2.17.153\\bin\\1cv8.exe" - pathbin1c = "c:\\Program Files (x86)\\1cv8\\8.3.4.304\\bin\\1cv8.exe" + #pathbin1c = "C:\\Program Files\\1cv82\8.2.17.153\\bin\\1cv8.exe" + #pathbin1c = "c:\\Program Files (x86)\\1cv8\\8.3.4.304\\bin\\1cv8.exe" + pathbin1c = get_path_to_1c() for filename in dataprocessor_files: print("file %s" % filename)