This file is indexed.

/usr/lib/python2.7/dist-packages/trytond/monitor.py is in tryton-server 3.4.0-3+deb8u3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#This file is part of Tryton.  The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import sys
import os
import subprocess
from threading import Lock
from trytond.modules import get_module_list

_LOCK = Lock()
_TIMES = {}
_MODULES = None


def _modified(path):
    _LOCK.acquire()
    try:
        try:
            if not os.path.isfile(path):
                return path in _TIMES

            mtime = os.stat(path).st_mtime
            if path not in _TIMES:
                _TIMES[path] = mtime

            if mtime != _TIMES[path]:
                _TIMES[path] = mtime
                return True
        except Exception:
            return True
    finally:
        _LOCK.release()
    return False


def monitor(files):
    '''
    Monitor files and module files for change

    :return: True if at least one file has changed
    '''
    global _MODULES
    modified = False
    for file_ in files:
        if _modified(file_):
            modified = True
    directories = set()
    for module in sys.modules.keys():
        if not module.startswith('trytond.'):
            continue
        if not hasattr(sys.modules[module], '__file__'):
            continue
        path = getattr(sys.modules[module], '__file__')
        if not path:
            continue
        if os.path.splitext(path)[1] in ['.pyc', '.pyo', '.pyd']:
            path = path[:-1]
        if _modified(path):
            if subprocess.call((sys.executable, '-c', 'import %s' % module),
                    cwd=os.path.dirname(os.path.abspath(os.path.normpath(
                        os.path.join(__file__, '..'))))):
                modified = False
                break
            modified = True

        # Check view XML
        directory = os.path.dirname(path)
        if directory not in directories:
            directories.add(directory)
            view_dir = os.path.join(directory, 'view')
            if os.path.isdir(view_dir):
                for view in os.listdir(view_dir):
                    view = os.path.join(view_dir, view)
                    if os.path.splitext(view)[1] == '.xml':
                        if _modified(view):
                            modified = True

    modules = set(get_module_list())
    if _MODULES is None:
        _MODULES = modules
    for module in modules.difference(_MODULES):
        if subprocess.call((sys.executable, '-c',
                    'import trytond.modules.%s' % module)):
            modified = False
            break
        modified = True
    _MODULES = modules
    return modified