()
| 1110 | |
| 1111 | |
| 1112 | def get_system_memory(): |
| 1113 | try: |
| 1114 | if LINUX or emrun_options.android: |
| 1115 | if emrun_options.android: |
| 1116 | lines = check_output([ADB, 'shell', 'cat', '/proc/meminfo']).split('\n') |
| 1117 | else: |
| 1118 | mem = open('/proc/meminfo', encoding='utf-8') |
| 1119 | lines = mem.readlines() |
| 1120 | mem.close() |
| 1121 | for i in lines: |
| 1122 | sline = i.split() |
| 1123 | if str(sline[0]) == 'MemTotal:': |
| 1124 | return int(sline[1]) * 1024 |
| 1125 | elif WINDOWS: |
| 1126 | import win32api |
| 1127 | return win32api.GlobalMemoryStatusEx()['TotalPhys'] |
| 1128 | elif MACOS: |
| 1129 | return int(check_output(['sysctl', '-n', 'hw.memsize']).strip()) |
| 1130 | elif FREEBSD: |
| 1131 | return int(check_output(['sysctl', '-n', 'hw.physmem']).strip()) |
| 1132 | except Exception: |
| 1133 | return -1 |
| 1134 | |
| 1135 | |
| 1136 | # Finds the given executable 'program' in PATH. Operates like the Unix tool 'which'. |
no test coverage detected