111 | uprocd is a "process preloader" or "process cache" for Linux systems. It starts
112 | a process (referred to as a module) in the background, then freezes it once
113 | initialization is completed. When you ask uprocd to run that module, it forks it and
114 | attaches the forked version to your terminal. This means that processes are only
115 | initialized once, so you don't have to wait around after starting a process.
116 |
117 |
118 | In other words: many programs will have a "daemon mode", where a copy of the program
119 | is running in the background, in order to improve startup speed. uprocd uses the
120 | same principle, except it is designed to be more generic: any application author
121 | can easily create a uprocd module in order to make their application's start-up
122 | time faster.
140 | The uprocd version is faster because a copy of IPython was already running. That
141 | copy was just forked and attached to the current terminal.
159 | A systemd-powered
160 | Linux system. uprocd itself only spawns daemons for each module and manages
161 | communication with them. systemd is used for both managing the daemons (via
162 |
163 | systemctl) and internally used for communication (via
164 | sd-bus).
165 |
166 |
167 | Optional:mrkd if you want
168 | to build the man pages.
198 | # Start the uprocd Python module. This will start Python in the background, then
199 | # freeze it until later.
200 | $ systemctl --user start uprocd@python
201 | # Have the module be automatically started at every boot.
202 | $ systemctl --user enable uprocd@python
203 |
204 | # Run Python via uprocd. This will fork the background process and bring the forked
205 | # one to the foreground.
206 | $ uprocctl run python -h
207 | # u is a shortcut for uprocctl run
208 | $ u python -h
209 | # upython is an included shortcut for u python
210 | $ upython -h
211 |
212 | # In fact, any symlink to uprocctl beginning with the letter u is a shortcut. e.g.
213 | # a symlink named uipython is a shortcut for uprocctl run ipython:
214 | $ uipython
215 | # Same as:
216 | $ u ipython
217 | # Same as:
218 | $ uprocctl run ipython
219 |
220 |
221 |
222 | For more information, see the man pages via man uprocd.index, or
223 | view them online.
240 | Android's
241 | Zygote does something similar to ensure the VM is already warmed up: it loads
242 | once, then forks off into other processes with an already-warmed VM.
253 | It shouldn't affect it that much. For instance, leaving uprocd's IPython module
254 | running in the background won't affect your memory usage much more than keeping
255 | IPython open all the time.
256 |
257 |
258 | Now in theory, uprocd could actually decrease memory usage: since forks are
259 | copy-on-write, any memory that isn't written two would be shared between processes.
260 | However, all the current uprocd modules (Python and Ruby) use interpreted,
261 | garbage-collected languages, and the second the GC touches a memory page, it will be
262 | copied.
263 |
264 |
265 | If a uprocd module were created for program written in a non-GC'd language, it would
266 | be more likely to show decreased memory usage.
271 | Yes. In theory, this isn't much of a loss: systemd's parallelism helps ensure that
272 | uprocd alone won't hold back your entire boot, and I personally haven't noticed
273 | any significant slowdowns.
274 |
275 |
276 | That being said, if you want the stats: the Python modules each take around 2s to
277 | start. Not sure about Ruby, since I don't have it enabled on boot. For comparison,
278 | Docker takes a little over 3s.
283 | Check out the GitHub repo for
284 | the source code. Extra modules that are either really useful or really cool can
285 | be suggested for inclusion.
286 |
287 |
Also be sure to file any bugs there!
288 |
289 |
--------------------------------------------------------------------------------
/src/cgrmvd/cgrmvd.c:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 |
5 | #include "common.h"
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | void _fail(sds message) {
16 | int errno_ = errno;
17 |
18 | fprintf(stderr, SD_CRIT "%.*s\n", (int)sdslen(message), message);
19 | sd_notifyf(0, "STATUS=\"Failure: %s\"", message);
20 | sdsfree(message);
21 |
22 | errno = errno_;
23 | }
24 |
25 | void _busfail(sd_bus_error *err, sds message) {
26 | _fail(sdsdup(message));
27 | sd_bus_error_set(err, "com.refi64.cgrmvd.Error", message);
28 | sdsfree(message);
29 | }
30 |
31 | #define FMT(...) sdscatfmt(sdsempty(), __VA_ARGS__)
32 | #define FAIL(...) _fail(FMT(__VA_ARGS__))
33 | #define BUSFAIL(err, ...) _busfail(err, FMT(__VA_ARGS__))
34 |
35 | typedef struct policy_origins {
36 | sds *origins;
37 | int len;
38 | } policy_origins;
39 |
40 | table g_policies;
41 |
42 | void free_policy(policy_origins *policy) {
43 | sdsfreesplitres(policy->origins, policy->len);
44 | }
45 |
46 | void read_policy(sds path) {
47 | FILE *fp = fopen(path, "r");
48 | if (fp == NULL) {
49 | FAIL("Error opening %S: %s", path, strerror(errno));
50 | return;
51 | }
52 |
53 | sds line = NULL;
54 | int rc = 0, lineno = 0;
55 |
56 | while ((rc = readline(fp, &line)) == 0 && line != NULL) {
57 | lineno++;
58 | sdstrim(line, "\t ");
59 |
60 | size_t len = sdslen(line);
61 | if (len == 0 || line[0] == '#') {
62 | goto parse_end;
63 | }
64 |
65 | char *mid = strstr(line, " : ");
66 | if (mid == NULL) {
67 | FAIL("Error parsing %S:%d.");
68 | goto parse_end;
69 | }
70 |
71 | sds copier = sdsdup(line), origins = sdsdup(line);
72 | sdsrange(copier, 0, mid - line - 1);
73 | sdsrange(origins, mid - line + 3, -1);
74 |
75 | policy_origins *policy = new(policy_origins);
76 | policy->origins = sdssplitlen(origins, sdslen(origins), " ", 1, &policy->len);
77 |
78 | policy_origins *original = table_swap(&g_policies, copier, policy);
79 | if (original != NULL) {
80 | FAIL("WARNING: Copier %s has multiple origin values", copier);
81 | free_policy(original);
82 | }
83 |
84 | sdsfree(copier);
85 | sdsfree(origins);
86 |
87 | parse_end:
88 | sdsfree(line);
89 | }
90 |
91 | fclose(fp);
92 | }
93 |
94 | void reload_policies() {
95 | table_free(&g_policies);
96 | table_init(&g_policies);
97 |
98 | DIR *dir;
99 | struct dirent *entry;
100 |
101 | char *root = "/usr/share/cgrmvd/policies";
102 | dir = opendir(root);
103 | if (dir == NULL) {
104 | FAIL("Error opening %s: %s", root, strerror(errno));
105 | return;
106 | }
107 |
108 | for (;;) {
109 | errno = 0;
110 | entry = readdir(dir);
111 | if (entry == NULL) {
112 | break;
113 | }
114 |
115 | if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
116 | continue;
117 | }
118 |
119 | sds name = sdsnew(entry->d_name);
120 | int len = sdslen(name);
121 | if (len < 8 || strcmp(name + len - 7, ".policy") != 0) {
122 | FAIL("Invalid file path (expected .policy): %S", name);
123 | goto loop_end;
124 | }
125 |
126 | sds path = sdscatfmt(sdsnew(root), "/%S", name);
127 | read_policy(path);
128 | sdsfree(path);
129 |
130 | loop_end:
131 | sdsfree(name);
132 | }
133 |
134 | closedir(dir);
135 | }
136 |
137 | int readlink_bus(sds path, sds *out, sd_bus_error *err) {
138 | char buf[PATH_MAX + 1];
139 | ssize_t sz = readlink(path, buf, sizeof(buf) - 1);
140 |
141 | if (sz == -1) {
142 | BUSFAIL(err, "Error reading link behind %S: %s", path, strerror(errno));
143 | sdsfree(path);
144 | return -errno;
145 | }
146 |
147 | *out = sdsnewlen(buf, sz);
148 | sdsfree(path);
149 |
150 | struct stat st;
151 | if (lstat(*out, &st) == -1) {
152 | FAIL("WARNING: lstat on %S from readlink_bus failed: %s", *out, strerror(errno));
153 | } else {
154 | if (S_ISLNK(st.st_mode)) {
155 | return readlink_bus(sdsdup(*out), out, err);
156 | }
157 | }
158 |
159 | return 0;
160 | }
161 |
162 | int fopen_bus(sds path, FILE **out, char *mode, sd_bus_error *err) {
163 | *out = fopen(path, mode);
164 |
165 | if (*out == NULL) {
166 | BUSFAIL(err, "Error reading %S: %s", path, strerror(errno));
167 | sdsfree(path);
168 | return -errno;
169 | }
170 |
171 | sdsfree(path);
172 | return 0;
173 | }
174 |
175 | int verify_policy(int64_t copier, int64_t origin, sd_bus_error *err) {
176 | sds copier_exe, origin_exe;
177 | int rc;
178 |
179 | rc = readlink_bus(sdscatfmt(sdsempty(), "/proc/%I/exe", copier), &copier_exe, err);
180 | if (rc < 0) {
181 | return rc;
182 | }
183 |
184 | rc = readlink_bus(sdscatfmt(sdsempty(), "/proc/%I/exe", origin), &origin_exe, err);
185 | if (rc < 0) {
186 | sdsfree(copier_exe);
187 | return rc;
188 | }
189 |
190 | policy_origins *policy = table_get(&g_policies, copier_exe);
191 | if (policy == NULL) {
192 | BUSFAIL(err, "Policy for %S does not exist.", copier_exe);
193 | return -EPERM;
194 | }
195 |
196 | int origin_match = 0;
197 | for (int i = 0; i < policy->len; i++) {
198 | if (strcmp(origin_exe, policy->origins[i]) == 0) {
199 | origin_match = 1;
200 | break;
201 | }
202 | }
203 |
204 | if (!origin_match) {
205 | BUSFAIL(err, "Policy for %S does not include origin %S.", copier_exe, origin_exe);
206 | return -EPERM;
207 | }
208 |
209 | return 0;
210 | }
211 |
212 | int parse_cgroup_path(int64_t pid, FILE *fp, sds *path, sd_bus_error *err) {
213 | sds line = NULL;
214 | int rc = 0, nparts = 0;
215 | sds *parts;
216 |
217 | rc = readline(fp, &line);
218 | if (rc < 0) {
219 | BUSFAIL(err, "Error reading line from /proc/%I/cgroup: %s", pid, strerror(errno));
220 | return -errno;
221 | }
222 |
223 | if (line == NULL) {
224 | *path = NULL;
225 | return 0;
226 | }
227 |
228 | parts = sdssplitlen(line, sdslen(line), ":", 1, &nparts);
229 | if (nparts != 3) {
230 | BUSFAIL(err, "Invalid line in /proc/%I/cgroup: %S", pid, line);
231 | rc = -EINVAL;
232 | goto end;
233 | }
234 |
235 | if (strncmp(parts[1], "name=", 5) == 0) {
236 | sdsrange(parts[1], 5, -1);
237 | }
238 |
239 | if (sdslen(parts[1]) == 0) {
240 | sdsfree(parts[1]);
241 | parts[1] = sdsnew("unified");
242 | }
243 |
244 | *path = sdscatfmt(sdsempty(), "/sys/fs/cgroup/%S%S", parts[1], parts[2]);
245 | if ((*path)[sdslen(*path) - 1] == '/') {
246 | sdsrange(*path, 0, -2);
247 | }
248 |
249 | end:
250 | sdsfree(line);
251 |
252 | if (parts) {
253 | sdsfreesplitres(parts, nparts);
254 | }
255 | return rc;
256 | }
257 |
258 | int move_cgroups(int64_t copier, int64_t origin, sd_bus_error *err) {
259 | FILE *copier_fp = NULL, *origin_fp = NULL;
260 | int rc = 0;
261 |
262 | rc = fopen_bus(sdscatfmt(sdsempty(), "/proc/%I/cgroup", copier), &copier_fp, "r", err);
263 | if (rc < 0) {
264 | goto end;
265 | }
266 |
267 | rc = fopen_bus(sdscatfmt(sdsempty(), "/proc/%I/cgroup", origin), &origin_fp, "r", err);
268 | if (rc < 0) {
269 | goto end;
270 | }
271 |
272 | for (;;) {
273 | sds copier_path = NULL, origin_path = NULL;
274 |
275 | rc = parse_cgroup_path(origin, origin_fp, &origin_path, err);
276 | if (rc < 0 || origin_path == NULL) {
277 | goto end;
278 | }
279 |
280 | rc = parse_cgroup_path(copier, copier_fp, &copier_path, err);
281 | if (rc < 0 || copier_path == NULL) {
282 | sdsfree(origin_path);
283 | goto end;
284 | }
285 |
286 | if (strcmp(origin_path, copier_path) == 0) {
287 | goto loop_end;
288 | }
289 |
290 | sds target = sdscat(sdsdup(origin_path), "/tasks");
291 | if (access(target, W_OK) != 0) {
292 | sdsfree(target);
293 | target = sdscat(sdsdup(origin_path), "/cgroup.procs");
294 | if (access(target, W_OK) != 0) {
295 | sdsfree(target);
296 | BUSFAIL(err, "Neither %S/tasks or %S/cgroup.procs are writable.", copier_path,
297 | copier_path);
298 | rc = -EACCES;
299 | goto loop_end;
300 | }
301 | }
302 |
303 | FILE *target_fp;
304 | rc = fopen_bus(target, &target_fp, "wa", err);
305 | if (rc < 0) {
306 | goto loop_end;
307 | }
308 |
309 | fprintf(target_fp, "%ld\n", copier);
310 | fclose(target_fp);
311 |
312 | loop_end:
313 | sdsfree(copier_path);
314 | sdsfree(origin_path);
315 | if (rc < 0) {
316 | break;
317 | }
318 | }
319 |
320 | end:
321 | if (copier_fp) {
322 | fclose(copier_fp);
323 | }
324 | if (origin_fp) {
325 | fclose(origin_fp);
326 | }
327 | return rc;
328 | }
329 |
330 | int service_method_move_cgroup(sd_bus_message *msg, void *data, sd_bus_error *err) {
331 | int64_t copier, origin;
332 | int rc;
333 |
334 | rc = sd_bus_message_read(msg, "xx", &copier, &origin);
335 | if (rc < 0) {
336 | FAIL("Error parsing bus message: %s", strerror(-rc));
337 | return rc;
338 | }
339 |
340 | rc = verify_policy(copier, origin, err);
341 | if (rc < 0) {
342 | return rc;
343 | }
344 |
345 | rc = move_cgroups(copier, origin, err);
346 | if (rc < 0) {
347 | return rc;
348 | }
349 |
350 | return sd_bus_reply_method_return(msg, "");
351 | }
352 |
353 | static const sd_bus_vtable service_vtable[] = {
354 | SD_BUS_VTABLE_START(0),
355 | // MoveCgroup(Int64 copier_pid, Int64 origin_pid)
356 | SD_BUS_METHOD("MoveCgroup", "xx", "", service_method_move_cgroup,
357 | SD_BUS_VTABLE_UNPRIVILEGED),
358 | SD_BUS_VTABLE_END
359 | };
360 |
361 | void bus_loop() {
362 | // XXX: This code is similar to uprocd/bus.c.
363 | int rc;
364 | sd_bus *bus = NULL;
365 | sd_bus_slot *slot = NULL;
366 |
367 | rc = sd_bus_open_system(&bus);
368 | if (rc < 0) {
369 | FAIL("sd_bus_open_user failed: %s", strerror(-rc));
370 | goto end;
371 | }
372 |
373 | rc = sd_bus_add_object_vtable(bus, &slot, "/com/refi64/uprocd/Cgrmvd",
374 | "com.refi64.uprocd.Cgrmvd", service_vtable, NULL);
375 | if (rc < 0) {
376 | FAIL("sd_bus_add_object_vtable failed: %s", strerror(-rc));
377 | goto end;
378 | }
379 |
380 | rc = sd_bus_request_name(bus, "com.refi64.uprocd.Cgrmvd", 0);
381 | if (rc < 0) {
382 | FAIL("sd_bus_request_name failed: %s", strerror(-rc));
383 | goto end;
384 | }
385 |
386 | for (;;) {
387 | rc = sd_bus_process(bus, NULL);
388 | if (rc < 0) {
389 | FAIL("sd_bus_process failed: %s", strerror(-rc));
390 | goto end;
391 | } else if (rc > 0) {
392 | continue;
393 | }
394 |
395 | rc = sd_bus_wait(bus, (uint64_t)-1);
396 | if (rc < 0 && rc != -EINTR) {
397 | FAIL("sd_bus_wait failed: %s", strerror(-rc));
398 | goto end;
399 | }
400 | }
401 |
402 | end:
403 | sd_bus_slot_unref(slot);
404 | sd_bus_unref(bus);
405 | }
406 |
407 | int main(int argc, char **argv) {
408 | table_init(&g_policies);
409 |
410 | signal(SIGHUP, reload_policies);
411 | reload_policies();
412 |
413 | bus_loop();
414 | }
415 |
--------------------------------------------------------------------------------
/src/uprocctl/main.c:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 |
5 | #include "common.h"
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | extern char **environ;
15 | int64_t target_pid = -1;
16 |
17 | #define STATUS_USAGE "status [-h] module"
18 | #define RUN_USAGE "run [-h] module [args...]"
19 | #define U_USAGE "[-h] module [args...]"
20 |
21 | void _fail(sds message) {
22 | fprintf(stderr, "uprocctl: %s\n", message);
23 | sdsfree(message);
24 | }
25 |
26 | #define FAIL(...) _fail(sdscatfmt(sdsempty(), __VA_ARGS__))
27 |
28 | char * last_path_component(char *path) {
29 | char *p = strrchr(path, '/');
30 | return p ? p + 1 : path;
31 | }
32 |
33 | void usage() {
34 | puts("usage: uprocctl -h");
35 | puts(" uprocctl " STATUS_USAGE);
36 | puts(" uprocctl " RUN_USAGE);
37 | puts(" u " U_USAGE);
38 | }
39 |
40 | void status_usage() {
41 | puts("usage: uprocctl " STATUS_USAGE);
42 | }
43 |
44 | void run_usage() {
45 | puts("usage: uprocctl " RUN_USAGE);
46 | }
47 |
48 | void u_usage() {
49 | puts("usage: u " U_USAGE);
50 | }
51 |
52 | void help() {
53 | puts("uprocctl allows you to communicate with uprocd modules.");
54 | puts("");
55 | puts("Commands:");
56 | puts("");
57 | puts(" status Show the status of a uprocd module.");
58 | puts(" run Run a command through a uprocd module.");
59 | puts("");
60 | puts("The u command is a shortcut for uprocctl run.");
61 | }
62 |
63 | void status_help() {
64 | puts("uprocctl status shows the status of the given uprocd module.");
65 | puts("");
66 | puts(" -h Show this screen.");
67 | puts(" module The uprocd module to retrieve information for.");
68 | }
69 |
70 | void run_help_base(int u) {
71 | puts("uprocctl run allows you to spawn commands via the uprocd modules.");
72 | if (u) {
73 | puts("u is a shortcut for uprocctl run.");
74 | }
75 | puts("");
76 | puts(" -h Show this screen.");
77 | puts(" module The uprocd module to run.");
78 | puts(" [args...] Command line arguments to pass to the module.");
79 | }
80 |
81 | void run_help() {
82 | run_help_base(0);
83 | }
84 |
85 | void u_help() {
86 | run_help_base(1);
87 | }
88 |
89 | void killme(int sig) {
90 | signal(sig, SIG_DFL);
91 | if (raise(sig) != 0) {
92 | FAIL("raise failed: %s", strerror(errno));
93 | abort();
94 | }
95 | }
96 |
97 | int status(const char *module) {
98 | sd_bus *bus = NULL;
99 | sd_bus_message *msg = NULL, *reply = NULL;
100 | sd_bus_error err = SD_BUS_ERROR_NULL;
101 | int rc;
102 |
103 | rc = sd_bus_open_user(&bus);
104 | if (rc < 0) {
105 | FAIL("sd_bus_open_user failed: %s", strerror(-rc));
106 | goto end;
107 | }
108 |
109 | sds service, object;
110 | get_bus_params(module, &service, &object);
111 |
112 | rc = sd_bus_message_new_method_call(bus, &msg, service, object, service, "Status");
113 | if (rc < 0) {
114 | FAIL("sd_bus_message_new_method_call failed: %s", strerror(-rc));
115 | goto end;
116 | }
117 |
118 | rc = sd_bus_call(bus, msg, 0, &err, &reply);
119 | if (rc < 0) {
120 | FAIL("sd_bus_call failed: %s", err.message);
121 | FAIL("Are you sure the uprocd module has been started?");
122 | goto end;
123 | }
124 |
125 | char *name, *description;
126 | rc = sd_bus_message_read(reply, "ss", &name, &description);
127 | if (rc < 0) {
128 | FAIL("uprocd process bus failed to return status information.");
129 | goto end;
130 | }
131 |
132 | printf("Name: %s\n", name);
133 | printf("Description: %s\n", description);
134 |
135 | end:
136 | sd_bus_error_free(&err);
137 | if (msg) {
138 | sd_bus_message_unref(msg);
139 | }
140 | if (bus) {
141 | sd_bus_unref(bus);
142 | }
143 |
144 | if (rc < 0) {
145 | return 1;
146 | } else {
147 | return 0;
148 | }
149 | }
150 |
151 | int wait_for_process() {
152 | if (ptrace(PTRACE_SEIZE, target_pid, NULL,
153 | (void*)(PTRACE_O_EXITKILL | PTRACE_O_TRACEEXIT)) == -1) {
154 | FAIL("Error seizing %I via ptrace: %s", target_pid, strerror(errno));
155 | return 1;
156 | }
157 |
158 | for (;;) {
159 | int wstatus;
160 | if (waitpid(target_pid, &wstatus, 0) == -1) {
161 | FAIL("waitpid: %s", strerror(errno));
162 | return 1;
163 | }
164 |
165 | if (wstatus >> 8 == (SIGTRAP | (PTRACE_EVENT_EXIT << 8))) {
166 | unsigned long pstatus;
167 | if (ptrace(PTRACE_GETEVENTMSG, target_pid, NULL, &pstatus) == -1) {
168 | FAIL("PTRACE_GETEVENTMSG failed: %s", strerror(errno));
169 | return 0;
170 | }
171 |
172 | return WEXITSTATUS(pstatus);
173 | } else if (WIFSTOPPED(wstatus) || WIFSIGNALED(wstatus)) {
174 | killme(WIFSTOPPED(wstatus) ? WSTOPSIG(wstatus) : WTERMSIG(wstatus));
175 | return 0;
176 | } else if (WIFEXITED(wstatus)) {
177 | return WEXITSTATUS(wstatus);
178 | } else {
179 | FAIL("waitpid gave unexpected status: %d\n", wstatus);
180 | }
181 | }
182 | }
183 |
184 | void forward_signal(int sig) {
185 | if (target_pid < 1) {
186 | FAIL("target_pid == %I in forward_signal", target_pid);
187 | abort();
188 | }
189 | kill(target_pid, sig);
190 | }
191 |
192 | int run(char *module, int argc, char **argv) {
193 | sd_bus *bus = NULL;
194 | sd_bus_message *msg = NULL, *reply = NULL;
195 | sd_bus_error err = SD_BUS_ERROR_NULL;
196 | int rc;
197 | char *title;
198 |
199 | char *cwd = getcwd(NULL, 0);
200 | if (cwd == NULL) {
201 | FAIL("Error retrieving current working directory: %s", strerror(errno));
202 | rc = -errno;
203 | goto end;
204 | }
205 |
206 | rc = sd_bus_open_user(&bus);
207 | if (rc < 0) {
208 | FAIL("sd_bus_open_user failed: %s", strerror(-rc));
209 | goto end;
210 | }
211 |
212 | sds service, object;
213 | get_bus_params(module, &service, &object);
214 |
215 | rc = sd_bus_message_new_method_call(bus, &msg, service, object, service, "Run");
216 | if (rc < 0) {
217 | FAIL("sd_bus_message_new_method_call failed: %s", strerror(-rc));
218 | goto end;
219 | }
220 |
221 | rc = sd_bus_message_open_container(msg, 'a', "{ss}");
222 | if (rc < 0) {
223 | goto write_end;
224 | }
225 |
226 | for (char **p = environ; *p; p++) {
227 | rc = sd_bus_message_open_container(msg, 'e', "ss");
228 | if (rc < 0) {
229 | goto write_end;
230 | }
231 |
232 | sds env = sdsnew(*p), key = sdsdup(env), value = sdsdup(env);
233 | sds eq = strchr(env, '=');
234 | sdsrange(key, 0, eq - env - 1);
235 | sdsrange(value, eq - env + 1, -1);
236 |
237 | rc = sd_bus_message_append(msg, "ss", key, value);
238 | sdsfree(key);
239 | sdsfree(value);
240 | if (rc < 0) {
241 | goto write_end;
242 | }
243 |
244 | rc = sd_bus_message_close_container(msg);
245 | if (rc < 0) {
246 | goto write_end;
247 | }
248 | }
249 |
250 | rc = sd_bus_message_close_container(msg);
251 | if (rc < 0) {
252 | goto write_end;
253 | }
254 |
255 | rc = sd_bus_message_open_container(msg, 'a', "s");
256 | if (rc < 0) {
257 | goto write_end;
258 | }
259 |
260 | for (int i = 0; i < argc; i++) {
261 | rc = sd_bus_message_append_basic(msg, 's', argv[i]);
262 | if (rc < 0) {
263 | goto write_end;
264 | }
265 | }
266 |
267 | rc = sd_bus_message_close_container(msg);
268 | if (rc < 0) {
269 | goto write_end;
270 | }
271 |
272 | rc = sd_bus_message_append(msg, "s(hhh)x", cwd, dup(0), dup(1), dup(2), getpid());
273 | if (rc < 0) {
274 | goto write_end;
275 | }
276 |
277 | write_end:
278 | if (rc < 0) {
279 | FAIL("Error writing bus message: %s", strerror(-rc));
280 | goto end;
281 | }
282 |
283 | rc = sd_bus_call(bus, msg, 0, &err, &reply);
284 | if (rc < 0) {
285 | if (strcmp(err.name, SD_BUS_ERROR_SERVICE_UNKNOWN) == 0) {
286 | FAIL("Failed to locate %s's D-Bus service.", module);
287 | FAIL("Are you sure it has been started? (Try systemctl --user status uprocd@%s.)",
288 | module);
289 | } else {
290 | FAIL("sd_bus_call failed: %s", err.message);
291 | FAIL("Are you sure the uprocd module has been started?");
292 | }
293 | goto end;
294 | }
295 |
296 | rc = sd_bus_message_read(reply, "xs", &target_pid, &title);
297 | if (rc < 0) {
298 | FAIL("uprocd process bus failed to return the new PID.");
299 | goto end;
300 | }
301 |
302 | setproctitle("-%s", title);
303 |
304 | end:
305 | if (cwd) {
306 | free(cwd);
307 | }
308 | sd_bus_error_free(&err);
309 | if (msg) {
310 | sd_bus_message_unref(msg);
311 | }
312 | if (bus) {
313 | sd_bus_unref(bus);
314 | }
315 |
316 | if (rc < 0) {
317 | return 1;
318 | } else {
319 | for (int sig = 0; sig < 31; sig++) {
320 | if (sig == SIGCHLD) {
321 | continue;
322 | }
323 | signal(sig, forward_signal);
324 | }
325 |
326 | return wait_for_process();
327 | }
328 | }
329 |
330 | int check_command(const char *command, int argc, char **argv, int exact,
331 | void (*usage)(), void (*help)()) {
332 | int correct_number = exact ? argc == 1 : argc >= 1;
333 | if (!correct_number) {
334 | if (exact) {
335 | FAIL("%s requires exactly one argument.", command);
336 | } else {
337 | FAIL("%s requires at least one argument.", command);
338 | }
339 | usage();
340 | return -1;
341 | }
342 |
343 | int is_help = strcmp(argv[0], "-h") == 0;
344 | if (argv[0][0] == '-' && !is_help) {
345 | FAIL("Invalid argument: %s.", argv[0]);
346 | usage();
347 | return -1;
348 | }
349 |
350 | if (is_help) {
351 | usage();
352 | putchar('\n');
353 | help();
354 | return 1;
355 | }
356 |
357 | return 0;
358 | }
359 |
360 | int main(int argc, char **argv) {
361 | setproctitle_init(argc, argv);
362 |
363 | char *name = last_path_component(argv[0]);
364 |
365 | if (strcmp(name, "u") == 0) {
366 | int rc = check_command("u", argc - 1, argv + 1, 0, u_usage, u_help);
367 | if (rc) {
368 | return rc < 0 ? 1 : 0;
369 | }
370 | return run(argv[1], argc - 2, argv + 2);
371 | } else if (strncmp(name, "u", 1) == 0 && strcmp(name, "uprocctl") != 0) {
372 | return run(name + 1, argc - 1, argv + 1);
373 | } else {
374 | if (strcmp(name, "uprocctl") != 0) {
375 | FAIL("WARNING: argv[0] is not a recognized uprocd symlink. Assuming uprocctl...");
376 | }
377 |
378 | if (argc < 2) {
379 | FAIL("An argument is required.");
380 | usage();
381 | return 1;
382 | }
383 |
384 | if (strcmp(argv[1], "-h") == 0) {
385 | usage();
386 | putchar('\n');
387 | help();
388 | return 0;
389 | } else if (strcmp(argv[1], "status") == 0) {
390 | int rc = check_command("status", argc - 2, argv + 2, 1, status_usage, status_help);
391 | if (rc) {
392 | return rc < 0 ? 1 : 0;
393 | }
394 | return status(argv[2]);
395 | } else if (strcmp(argv[1], "run") == 0) {
396 | int rc = check_command("run", argc - 2, argv + 2, 0, run_usage, run_help);
397 | if (rc) {
398 | return rc < 0 ? 1 : 0;
399 | }
400 | return run(argv[2], argc - 3, argv + 3);
401 | } else {
402 | FAIL("Invalid command.");
403 | usage();
404 | return 1;
405 | }
406 | }
407 | }
408 |
--------------------------------------------------------------------------------
/fbuildroot.py:
--------------------------------------------------------------------------------
1 | from fbuild.builders.platform import guess_platform
2 | from fbuild.builders.pkg_config import PkgConfig
3 | from fbuild.builders.file import copy
4 | from fbuild.builders.c import guess
5 | from fbuild.builders import find_program
6 |
7 | from fbuild.config.c import header_test, Test
8 |
9 | from fbuild.target import register
10 | from fbuild.record import Record
11 | from fbuild.path import Path
12 | import fbuild.db
13 |
14 | from functools import partial
15 | import os, re
16 |
17 |
18 | class Module(Record): pass
19 |
20 |
21 | def arguments(parser):
22 | group = parser.add_argument_group('config options')
23 | group.add_argument('--cc', help='Use the given C compiler')
24 | group.add_argument('--cflag', help='Pass the given flag to the C compiler',
25 | action='append', default=[])
26 | group.add_argument('--use-color', help='Force C++ compiler colored output',
27 | action='store_true', default=True)
28 | group.add_argument('--release', help='Build in release mode',
29 | action='store_true', default=False)
30 | group.add_argument('--pkg-config', help='Use the given pkg-config executable')
31 | group.add_argument('--ruby', help='Use the given Ruby binary')
32 | group.add_argument('--mrkd', help='Use the given mrkd executable')
33 | group.add_argument('--destdir', help='Set the installation destdir', default='/')
34 | group.add_argument('--prefix', help='Set the installation prefix', default='usr')
35 | group.add_argument('--auto-service',
36 | help='Automatically stop services before installation',
37 | action='store_true', default=False)
38 |
39 |
40 | class Judy(Test):
41 | Judy_h = header_test('Judy.h')
42 |
43 |
44 | class MrkdBuilder(fbuild.db.PersistentObject):
45 | def __init__(self, ctx, exe=None):
46 | self.ctx = ctx
47 | self.mrkd = exe or find_program(ctx, ['mrkd'])
48 |
49 | @fbuild.db.cachemethod
50 | def convert(self, src: fbuild.db.SRC, *, index: fbuild.db.SRC, outdir, format):
51 | assert format in ('roff', 'html')
52 |
53 | src = Path(src)
54 | outdir = Path(outdir).addroot(self.ctx.buildroot)
55 | outdir.makedirs()
56 |
57 | ext = {'roff': '', 'html': '.html'}[format]
58 | dst = outdir / src.basename().replaceext(ext)
59 |
60 | cmd = [self.mrkd, src, dst, '-index', index, '-format', format]
61 | self.ctx.execute(cmd, 'mrkd', '%s -> %s' % (src, dst), color='yellow')
62 | self.ctx.db.add_external_dependencies_to_call(dsts=[dst])
63 | return dst
64 |
65 |
66 | @fbuild.db.caches
67 | def ruby_version(ctx, ruby_bin):
68 | ctx.logger.check('checking %s version' % ruby_bin)
69 | out, _ = ctx.execute([ruby_bin, '--version'], quieter=1)
70 | m = re.match(r'ruby (\d\.\d)', out.decode('utf-8'))
71 | if m is None:
72 | ctx.logger.failed()
73 | return None
74 | ctx.logger.passed(m.group(1))
75 | return m.group(1)
76 |
77 |
78 | @fbuild.db.caches
79 | def run_pkg_config(ctx, package):
80 | ctx.logger.check('checking for %s' % package)
81 | pkg = PkgConfig(ctx, package, exe=ctx.options.pkg_config)
82 |
83 | try:
84 | cflags = pkg.cflags()
85 | ldlibs = pkg.libs()
86 | except fbuild.ExecutionError:
87 | ctx.logger.failed()
88 | return None
89 |
90 | ctx.logger.passed(' '.join(cflags + ldlibs))
91 | return Record(cflags=cflags, ldlibs=ldlibs)
92 |
93 |
94 | def print_config(ctx, rec):
95 | def padprint(c, msg):
96 | total = len(msg) + 22
97 | print(c * total)
98 | print(c * 10, msg, c * 10)
99 | print(c * total)
100 |
101 | def optprint(tag, value):
102 | print(tag, 'Yes.' if value else 'No.')
103 |
104 | print()
105 | padprint('*', 'Configure results')
106 | print()
107 |
108 | optprint('Release mode:', ctx.options.release)
109 | print('C compiler:', rec.c.static.compiler.cc.exe)
110 | print('C compiler flags:', ' '.join(set(rec.c.static.compiler.flags)))
111 | print('C linker flags:', ' '.join(set(rec.c.static.exe_linker.flags)))
112 | optprint('Build docs:', rec.mrkd)
113 |
114 | print()
115 | padprint('=', 'Modules')
116 | print()
117 |
118 | optprint('Python module:', rec.python3)
119 | optprint('Ruby module:', rec.ruby)
120 | print()
121 |
122 |
123 | @fbuild.db.caches
124 | def _configure(ctx, print_):
125 | platform = guess_platform(ctx)
126 | if 'linux' not in platform:
127 | raise fbuild.ConfigFailed('uprocd only runs under Linux.')
128 |
129 | flags = ctx.options.cflag
130 | posix_flags = ['-Wall', '-Werror', '-Wno-strict-prototypes', '-Wno-sign-compare']
131 | clang_flags = []
132 |
133 | if ctx.options.use_color:
134 | posix_flags.append('-fdiagnostics-color')
135 | if ctx.options.release:
136 | debug = False
137 | optimize = True
138 | else:
139 | debug = True
140 | optimize = False
141 | clang_flags.append('-fno-limit-debug-info')
142 |
143 | c = guess(ctx, exe=ctx.options.cc, flags=flags,
144 | debug=debug, optimize=optimize, platform_options=[
145 | ({'clang'}, {'flags+': clang_flags}),
146 | ({'posix'}, {'flags+': posix_flags,
147 | 'external_libs+': ['dl']}),
148 | ])
149 |
150 | libsystemd = run_pkg_config(ctx, 'libsystemd')
151 | if libsystemd is None:
152 | raise fbuild.ConfigFailed('libsystemd is required.')
153 |
154 | python3 = run_pkg_config(ctx, 'python3')
155 |
156 | ruby_bin = ruby = None
157 | try:
158 | ruby_bin = ctx.options.ruby or find_program(ctx, ['ruby'])
159 | except fbuild.ConfigFailed:
160 | pass
161 | else:
162 | ruby_ver = ruby_version(ctx, ruby_bin)
163 | if ruby_ver is not None:
164 | ruby = run_pkg_config(ctx, 'ruby-%s' % ruby_ver)
165 |
166 | try:
167 | mrkd = MrkdBuilder(ctx, ctx.options.mrkd)
168 | except fbuild.ConfigFailed:
169 | mrkd = None
170 |
171 | if not Judy(c.static).Judy_h:
172 | raise fbuild.ConfigFailed('Judy is required.')
173 |
174 | try:
175 | systemctl = find_program(ctx, ['systemctl'])
176 | except fbuild.ConfigFailed:
177 | systemctl = None
178 |
179 | rec = Record(c=c, libsystemd=libsystemd, python3=python3, ruby_bin=ruby_bin,
180 | ruby=ruby, mrkd=mrkd, systemctl=systemctl)
181 | if print_:
182 | print_config(ctx, rec)
183 | return rec
184 |
185 |
186 | @register()
187 | def configure(ctx):
188 | print('NOTE: If you want to reconfigure, run fbuild configure --rebuild instead.')
189 | rec = _configure(ctx, print_=False)
190 | print_config(ctx, rec)
191 |
192 |
193 | @fbuild.db.caches
194 | def symlink(ctx, src: fbuild.db.SRC, dst) -> fbuild.db.DST:
195 | dst = Path(dst).addroot(ctx.buildroot)
196 | ctx.logger.check(' * symlink', '%s -> %s' % (src, dst), color='yellow')
197 |
198 | if dst.lexists():
199 | dst.remove()
200 | os.symlink(src.relpath(dst.parent), dst)
201 |
202 | return dst
203 |
204 |
205 | def build_module(ctx, module, *, rec, uprocctl):
206 | if 'pkg' in module:
207 | if module.pkg is None:
208 | return
209 | else:
210 | kw = {'cflags': module.pkg.cflags, 'ldlibs': module.pkg.ldlibs}
211 | else:
212 | kw = {}
213 |
214 | root = Path('modules') / module.name
215 |
216 | binaries = []
217 | module_data = []
218 |
219 | lib = rec.c.shared.build_lib(module.name, Path.glob('modules/%s/*.c' % module.name),
220 | includes=['api'], **kw)
221 |
222 | module_data.append(copy(ctx, lib, (root / module.name).replaceext('.so')))
223 | for mod in [module.name] + module.others:
224 | path = (root / mod).replaceext('.module')
225 | module_data.append(copy(ctx, path, ctx.buildroot / path))
226 |
227 | for file in module.files:
228 | path = root / file
229 | module_data.append(copy(ctx, path, ctx.buildroot / path))
230 |
231 | for link in module.links:
232 | binaries.append(symlink(ctx, uprocctl, link))
233 |
234 | return Record(binaries=binaries, data=module_data)
235 |
236 |
237 | def build_docs(ctx, src, *, rec, index):
238 | outdirs = {'roff': 'man', 'html': 'web'}
239 | man, html = ctx.scheduler.map(lambda fm: rec.mrkd.convert(src=src, index=index,
240 | outdir=outdirs[fm], format=fm),
241 | ['roff', 'html'])
242 | return Record(man=man, html=html)
243 |
244 |
245 | def build(ctx):
246 | rec = _configure(ctx, print_=True)
247 | ctx.install_destdir = ctx.options.destdir
248 | ctx.install_prefix = ctx.options.prefix
249 |
250 | sds = rec.c.static.build_lib('sds', ['sds/sds.c'])
251 |
252 | common_kw = dict(
253 | includes=['api', 'sds', 'src/common'],
254 | cflags=['-fvisibility=hidden'] + rec.libsystemd.cflags,
255 | ldlibs=['-Wl,--export-dynamic'] + rec.libsystemd.ldlibs,
256 | external_libs=['Judy'],
257 | libs=[sds],
258 | )
259 |
260 | common = rec.c.static.build_lib('common', Path.glob('src/common/*.c'), **common_kw)
261 |
262 | # Avoid mutating the dict to ensure accurate rebuilds.
263 | common_kw = common_kw.copy()
264 | common_kw['libs'] = common_kw['libs'] + [common]
265 |
266 | cgrmvd = rec.c.static.build_exe('cgrmvd', Path.glob('src/cgrmvd/*.c'), **common_kw)
267 | uprocd = rec.c.static.build_exe('uprocd', Path.glob('src/uprocd/*.c'), **common_kw)
268 | uprocctl = rec.c.static.build_exe('uprocctl', Path.glob('src/uprocctl/*.c'),
269 | **common_kw)
270 | u = symlink(ctx, uprocctl, 'u')
271 |
272 | modules = [
273 | Module(name='python', pkg=rec.python3, sources='python.c',
274 | others=['ipython', 'mrkd', 'mypy'], files=['_uprocd_modules.py'],
275 | links=['upython', 'uipython', 'umrkd', 'umypy']),
276 | Module(name='ruby', pkg=rec.ruby, sources='ruby.c', others=[],
277 | files=['_uprocd_requires.rb'], links=['uruby']),
278 | ]
279 |
280 | module_outputs = ctx.scheduler.map(
281 | partial(build_module, ctx, rec=rec, uprocctl=uprocctl),
282 | modules)
283 |
284 | if rec.mrkd is None:
285 | return
286 |
287 | u_man = copy(ctx, 'man/uprocctl.1.md', 'md/u.1.md')
288 | page_out = ctx.scheduler.map(partial(build_docs, ctx, rec=rec,
289 | index='man/index.ini'),
290 | [u_man] + Path.glob('man/*.md'))
291 | u_man_out = page_out[0]
292 |
293 | copy(ctx, 'web/index.html', 'web')
294 |
295 | ctx.install(cgrmvd, 'share/uprocd/bin')
296 | ctx.install(uprocd, 'share/uprocd/bin')
297 | ctx.install(uprocctl, 'bin')
298 | ctx.install(u, 'bin')
299 |
300 | ctx.install('misc/uprocd@.service', 'lib/systemd/user')
301 | ctx.install('misc/cgrmvd.service', 'lib/systemd/system')
302 | ctx.install('misc/uprocd.policy', 'share/cgrmvd/policies')
303 | ctx.install('misc/com.refi64.uprocd.Cgrmvd.conf', '/etc/dbus-1/system.d')
304 |
305 | for i, output in enumerate(module_outputs):
306 | if output is None:
307 | man = '%s.module' % modules[i].name
308 | page_out = [page for page in page_out \
309 | if page.man.basename().replaceext('') != man]
310 | continue
311 |
312 | for bin in output.binaries:
313 | ctx.install(bin, 'bin')
314 | page_out.append(Record(man=u_man_out.man, rename='%s.1' % bin.basename()))
315 | for data in output.data:
316 | ctx.install(data, 'share/uprocd/modules')
317 |
318 | for page in page_out:
319 | rename = page.get('rename')
320 | section = page.man.ext.lstrip('.')
321 |
322 | ctx.install(page.man, 'share/man/man%s' % section, rename=rename)
323 |
324 |
325 | def pre_install(ctx):
326 | if ctx.options.auto_service:
327 | rec = _configure(ctx, print_=False)
328 | ctx.execute([rec.systemctl, 'stop', 'cgrmvd'], msg1='systemctl stop',
329 | msg2='cgrmvd', color='compile', ignore_error=True)
330 | ctx.execute([rec.systemctl, '--user', 'stop', 'uprocd.slice'],
331 | msg1='systemctl stop', msg2='uprocd (user)', color='compile',
332 | ignore_error=True)
333 |
334 |
335 | def post_install(ctx):
336 | if ctx.options.auto_service:
337 | rec = _configure(ctx, print_=False)
338 | ctx.execute([rec.systemctl, 'daemon-reload'], msg1='systemctl',
339 | msg2='daemon-reload', color='compile', ignore_error=True)
340 | ctx.execute([rec.systemctl, '--user', 'daemon-reload'], msg1='systemctl',
341 | msg2='daemon-reload (user)', color='compile', ignore_error=True)
342 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------
/modules/python/_uprocd_modules.py:
--------------------------------------------------------------------------------
1 |
2 | try:
3 | import string
4 | except Exception as ex:
5 | print('string', ex)
6 |
7 | try:
8 | import re
9 | except Exception as ex:
10 | print('re', ex)
11 |
12 | try:
13 | import difflib
14 | except Exception as ex:
15 | print('difflib', ex)
16 |
17 | try:
18 | import textwrap
19 | except Exception as ex:
20 | print('textwrap', ex)
21 |
22 | try:
23 | import unicodedata
24 | except Exception as ex:
25 | print('unicodedata', ex)
26 |
27 | try:
28 | import stringprep
29 | except Exception as ex:
30 | print('stringprep', ex)
31 |
32 | try:
33 | import readline
34 | except Exception as ex:
35 | print('readline', ex)
36 |
37 | try:
38 | import rlcompleter
39 | except Exception as ex:
40 | print('rlcompleter', ex)
41 |
42 | try:
43 | import struct
44 | except Exception as ex:
45 | print('struct', ex)
46 |
47 | try:
48 | import codecs
49 | except Exception as ex:
50 | print('codecs', ex)
51 |
52 | try:
53 | import datetime
54 | except Exception as ex:
55 | print('datetime', ex)
56 |
57 | try:
58 | import calendar
59 | except Exception as ex:
60 | print('calendar', ex)
61 |
62 | try:
63 | import collections
64 | except Exception as ex:
65 | print('collections', ex)
66 |
67 | try:
68 | import heapq
69 | except Exception as ex:
70 | print('heapq', ex)
71 |
72 | try:
73 | import bisect
74 | except Exception as ex:
75 | print('bisect', ex)
76 |
77 | try:
78 | import array
79 | except Exception as ex:
80 | print('array', ex)
81 |
82 | try:
83 | import weakref
84 | except Exception as ex:
85 | print('weakref', ex)
86 |
87 | try:
88 | import types
89 | except Exception as ex:
90 | print('types', ex)
91 |
92 | try:
93 | import copy
94 | except Exception as ex:
95 | print('copy', ex)
96 |
97 | try:
98 | import pprint
99 | except Exception as ex:
100 | print('pprint', ex)
101 |
102 | try:
103 | import reprlib
104 | except Exception as ex:
105 | print('reprlib', ex)
106 |
107 | try:
108 | import enum
109 | except Exception as ex:
110 | print('enum', ex)
111 |
112 | try:
113 | import numbers
114 | except Exception as ex:
115 | print('numbers', ex)
116 |
117 | try:
118 | import math
119 | except Exception as ex:
120 | print('math', ex)
121 |
122 | try:
123 | import cmath
124 | except Exception as ex:
125 | print('cmath', ex)
126 |
127 | try:
128 | import decimal
129 | except Exception as ex:
130 | print('decimal', ex)
131 |
132 | try:
133 | import fractions
134 | except Exception as ex:
135 | print('fractions', ex)
136 |
137 | try:
138 | import random
139 | except Exception as ex:
140 | print('random', ex)
141 |
142 | try:
143 | import statistics
144 | except Exception as ex:
145 | print('statistics', ex)
146 |
147 | try:
148 | import itertools
149 | except Exception as ex:
150 | print('itertools', ex)
151 |
152 | try:
153 | import functools
154 | except Exception as ex:
155 | print('functools', ex)
156 |
157 | try:
158 | import operator
159 | except Exception as ex:
160 | print('operator', ex)
161 |
162 | try:
163 | import pathlib
164 | except Exception as ex:
165 | print('pathlib', ex)
166 |
167 | try:
168 | import fileinput
169 | except Exception as ex:
170 | print('fileinput', ex)
171 |
172 | try:
173 | import stat
174 | except Exception as ex:
175 | print('stat', ex)
176 |
177 | try:
178 | import filecmp
179 | except Exception as ex:
180 | print('filecmp', ex)
181 |
182 | try:
183 | import tempfile
184 | except Exception as ex:
185 | print('tempfile', ex)
186 |
187 | try:
188 | import glob
189 | except Exception as ex:
190 | print('glob', ex)
191 |
192 | try:
193 | import fnmatch
194 | except Exception as ex:
195 | print('fnmatch', ex)
196 |
197 | try:
198 | import linecache
199 | except Exception as ex:
200 | print('linecache', ex)
201 |
202 | try:
203 | import shutil
204 | except Exception as ex:
205 | print('shutil', ex)
206 |
207 | try:
208 | import macpath
209 | except Exception as ex:
210 | print('macpath', ex)
211 |
212 | try:
213 | import pickle
214 | except Exception as ex:
215 | print('pickle', ex)
216 |
217 | try:
218 | import copyreg
219 | except Exception as ex:
220 | print('copyreg', ex)
221 |
222 | try:
223 | import pickle
224 | except Exception as ex:
225 | print('pickle', ex)
226 |
227 | try:
228 | import shelve
229 | except Exception as ex:
230 | print('shelve', ex)
231 |
232 | try:
233 | import marshal
234 | except Exception as ex:
235 | print('marshal', ex)
236 |
237 | try:
238 | import dbm
239 | except Exception as ex:
240 | print('dbm', ex)
241 |
242 | try:
243 | import sqlite3
244 | except Exception as ex:
245 | print('sqlite3', ex)
246 |
247 | try:
248 | import zlib
249 | except Exception as ex:
250 | print('zlib', ex)
251 |
252 | try:
253 | import gzip
254 | except Exception as ex:
255 | print('gzip', ex)
256 |
257 | try:
258 | import bz2
259 | except Exception as ex:
260 | print('bz2', ex)
261 |
262 | try:
263 | import lzma
264 | except Exception as ex:
265 | print('lzma', ex)
266 |
267 | try:
268 | import zipfile
269 | except Exception as ex:
270 | print('zipfile', ex)
271 |
272 | try:
273 | import tarfile
274 | except Exception as ex:
275 | print('tarfile', ex)
276 |
277 | try:
278 | import csv
279 | except Exception as ex:
280 | print('csv', ex)
281 |
282 | try:
283 | import configparser
284 | except Exception as ex:
285 | print('configparser', ex)
286 |
287 | try:
288 | import netrc
289 | except Exception as ex:
290 | print('netrc', ex)
291 |
292 | try:
293 | import xdrlib
294 | except Exception as ex:
295 | print('xdrlib', ex)
296 |
297 | try:
298 | import plistlib
299 | except Exception as ex:
300 | print('plistlib', ex)
301 |
302 | try:
303 | import hashlib
304 | except Exception as ex:
305 | print('hashlib', ex)
306 |
307 | try:
308 | import hmac
309 | except Exception as ex:
310 | print('hmac', ex)
311 |
312 | try:
313 | import secrets
314 | except Exception as ex:
315 | print('secrets', ex)
316 |
317 | try:
318 | import os
319 | except Exception as ex:
320 | print('os', ex)
321 |
322 | try:
323 | import io
324 | except Exception as ex:
325 | print('io', ex)
326 |
327 | try:
328 | import time
329 | except Exception as ex:
330 | print('time', ex)
331 |
332 | try:
333 | import argparse
334 | except Exception as ex:
335 | print('argparse', ex)
336 |
337 | try:
338 | import getopt
339 | except Exception as ex:
340 | print('getopt', ex)
341 |
342 | try:
343 | import logging
344 | except Exception as ex:
345 | print('logging', ex)
346 |
347 | try:
348 | import getpass
349 | except Exception as ex:
350 | print('getpass', ex)
351 |
352 | try:
353 | import curses
354 | except Exception as ex:
355 | print('curses', ex)
356 |
357 | try:
358 | import platform
359 | except Exception as ex:
360 | print('platform', ex)
361 |
362 | try:
363 | import errno
364 | except Exception as ex:
365 | print('errno', ex)
366 |
367 | try:
368 | import ctypes
369 | except Exception as ex:
370 | print('ctypes', ex)
371 |
372 | try:
373 | import threading
374 | except Exception as ex:
375 | print('threading', ex)
376 |
377 | try:
378 | import multiprocessing
379 | except Exception as ex:
380 | print('multiprocessing', ex)
381 |
382 | try:
383 | import concurrent
384 | except Exception as ex:
385 | print('concurrent', ex)
386 |
387 | try:
388 | import subprocess
389 | except Exception as ex:
390 | print('subprocess', ex)
391 |
392 | try:
393 | import sched
394 | except Exception as ex:
395 | print('sched', ex)
396 |
397 | try:
398 | import queue
399 | except Exception as ex:
400 | print('queue', ex)
401 |
402 | try:
403 | import dummy_threading
404 | except Exception as ex:
405 | print('dummy_threading', ex)
406 |
407 | try:
408 | import threading
409 | except Exception as ex:
410 | print('threading', ex)
411 |
412 | try:
413 | import socket
414 | except Exception as ex:
415 | print('socket', ex)
416 |
417 | try:
418 | import ssl
419 | except Exception as ex:
420 | print('ssl', ex)
421 |
422 | try:
423 | import select
424 | except Exception as ex:
425 | print('select', ex)
426 |
427 | try:
428 | import selectors
429 | except Exception as ex:
430 | print('selectors', ex)
431 |
432 | try:
433 | import asyncio
434 | except Exception as ex:
435 | print('asyncio', ex)
436 |
437 | try:
438 | import asyncore
439 | except Exception as ex:
440 | print('asyncore', ex)
441 |
442 | try:
443 | import asynchat
444 | except Exception as ex:
445 | print('asynchat', ex)
446 |
447 | try:
448 | import signal
449 | except Exception as ex:
450 | print('signal', ex)
451 |
452 | try:
453 | import mmap
454 | except Exception as ex:
455 | print('mmap', ex)
456 |
457 | try:
458 | import email
459 | except Exception as ex:
460 | print('email', ex)
461 |
462 | try:
463 | import json
464 | except Exception as ex:
465 | print('json', ex)
466 |
467 | try:
468 | import mailcap
469 | except Exception as ex:
470 | print('mailcap', ex)
471 |
472 | try:
473 | import mailbox
474 | except Exception as ex:
475 | print('mailbox', ex)
476 |
477 | try:
478 | import mimetypes
479 | except Exception as ex:
480 | print('mimetypes', ex)
481 |
482 | try:
483 | import base64
484 | except Exception as ex:
485 | print('base64', ex)
486 |
487 | try:
488 | import binhex
489 | except Exception as ex:
490 | print('binhex', ex)
491 |
492 | try:
493 | import binascii
494 | except Exception as ex:
495 | print('binascii', ex)
496 |
497 | try:
498 | import quopri
499 | except Exception as ex:
500 | print('quopri', ex)
501 |
502 | try:
503 | import uu
504 | except Exception as ex:
505 | print('uu', ex)
506 |
507 | try:
508 | import html
509 | except Exception as ex:
510 | print('html', ex)
511 |
512 | try:
513 | import webbrowser
514 | except Exception as ex:
515 | print('webbrowser', ex)
516 |
517 | try:
518 | import cgi
519 | except Exception as ex:
520 | print('cgi', ex)
521 |
522 | try:
523 | import cgitb
524 | except Exception as ex:
525 | print('cgitb', ex)
526 |
527 | try:
528 | import wsgiref
529 | except Exception as ex:
530 | print('wsgiref', ex)
531 |
532 | try:
533 | import urllib
534 | except Exception as ex:
535 | print('urllib', ex)
536 |
537 | try:
538 | import http
539 | except Exception as ex:
540 | print('http', ex)
541 |
542 | try:
543 | import ftplib
544 | except Exception as ex:
545 | print('ftplib', ex)
546 |
547 | try:
548 | import poplib
549 | except Exception as ex:
550 | print('poplib', ex)
551 |
552 | try:
553 | import imaplib
554 | except Exception as ex:
555 | print('imaplib', ex)
556 |
557 | try:
558 | import nntplib
559 | except Exception as ex:
560 | print('nntplib', ex)
561 |
562 | try:
563 | import smtplib
564 | except Exception as ex:
565 | print('smtplib', ex)
566 |
567 | try:
568 | import smtpd
569 | except Exception as ex:
570 | print('smtpd', ex)
571 |
572 | try:
573 | import telnetlib
574 | except Exception as ex:
575 | print('telnetlib', ex)
576 |
577 | try:
578 | import uuid
579 | except Exception as ex:
580 | print('uuid', ex)
581 |
582 | try:
583 | import socketserver
584 | except Exception as ex:
585 | print('socketserver', ex)
586 |
587 | try:
588 | import xmlrpc
589 | except Exception as ex:
590 | print('xmlrpc', ex)
591 |
592 | try:
593 | import ipaddress
594 | except Exception as ex:
595 | print('ipaddress', ex)
596 |
597 | try:
598 | import audioop
599 | except Exception as ex:
600 | print('audioop', ex)
601 |
602 | try:
603 | import aifc
604 | except Exception as ex:
605 | print('aifc', ex)
606 |
607 | try:
608 | import sunau
609 | except Exception as ex:
610 | print('sunau', ex)
611 |
612 | try:
613 | import wave
614 | except Exception as ex:
615 | print('wave', ex)
616 |
617 | try:
618 | import chunk
619 | except Exception as ex:
620 | print('chunk', ex)
621 |
622 | try:
623 | import colorsys
624 | except Exception as ex:
625 | print('colorsys', ex)
626 |
627 | try:
628 | import imghdr
629 | except Exception as ex:
630 | print('imghdr', ex)
631 |
632 | try:
633 | import sndhdr
634 | except Exception as ex:
635 | print('sndhdr', ex)
636 |
637 | try:
638 | import ossaudiodev
639 | except Exception as ex:
640 | print('ossaudiodev', ex)
641 |
642 | try:
643 | import gettext
644 | except Exception as ex:
645 | print('gettext', ex)
646 |
647 | try:
648 | import locale
649 | except Exception as ex:
650 | print('locale', ex)
651 |
652 | try:
653 | import turtle
654 | except Exception as ex:
655 | print('turtle', ex)
656 |
657 | try:
658 | import cmd
659 | except Exception as ex:
660 | print('cmd', ex)
661 |
662 | try:
663 | import shlex
664 | except Exception as ex:
665 | print('shlex', ex)
666 |
667 | try:
668 | import tkinter
669 | except Exception as ex:
670 | print('tkinter', ex)
671 |
672 | try:
673 | import typing
674 | except Exception as ex:
675 | print('typing', ex)
676 |
677 | try:
678 | import pydoc
679 | except Exception as ex:
680 | print('pydoc', ex)
681 |
682 | try:
683 | import doctest
684 | except Exception as ex:
685 | print('doctest', ex)
686 |
687 | try:
688 | import unittest
689 | except Exception as ex:
690 | print('unittest', ex)
691 |
692 | try:
693 | import test
694 | except Exception as ex:
695 | print('test', ex)
696 |
697 | try:
698 | import bdb
699 | except Exception as ex:
700 | print('bdb', ex)
701 |
702 | try:
703 | import faulthandler
704 | except Exception as ex:
705 | print('faulthandler', ex)
706 |
707 | try:
708 | import pdb
709 | except Exception as ex:
710 | print('pdb', ex)
711 |
712 | try:
713 | import timeit
714 | except Exception as ex:
715 | print('timeit', ex)
716 |
717 | try:
718 | import trace
719 | except Exception as ex:
720 | print('trace', ex)
721 |
722 | try:
723 | import tracemalloc
724 | except Exception as ex:
725 | print('tracemalloc', ex)
726 |
727 | try:
728 | import distutils
729 | except Exception as ex:
730 | print('distutils', ex)
731 |
732 | try:
733 | import ensurepip
734 | except Exception as ex:
735 | print('ensurepip', ex)
736 |
737 | try:
738 | import pip
739 | except Exception as ex:
740 | print('pip', ex)
741 |
742 | try:
743 | import venv
744 | except Exception as ex:
745 | print('venv', ex)
746 |
747 | try:
748 | import zipapp
749 | except Exception as ex:
750 | print('zipapp', ex)
751 |
752 | try:
753 | import sys
754 | except Exception as ex:
755 | print('sys', ex)
756 |
757 | try:
758 | import sysconfig
759 | except Exception as ex:
760 | print('sysconfig', ex)
761 |
762 | try:
763 | import builtins
764 | except Exception as ex:
765 | print('builtins', ex)
766 |
767 | try:
768 | import warnings
769 | except Exception as ex:
770 | print('warnings', ex)
771 |
772 | try:
773 | import contextlib
774 | except Exception as ex:
775 | print('contextlib', ex)
776 |
777 | try:
778 | import abc
779 | except Exception as ex:
780 | print('abc', ex)
781 |
782 | try:
783 | import atexit
784 | except Exception as ex:
785 | print('atexit', ex)
786 |
787 | try:
788 | import traceback
789 | except Exception as ex:
790 | print('traceback', ex)
791 |
792 | try:
793 | import gc
794 | except Exception as ex:
795 | print('gc', ex)
796 |
797 | try:
798 | import inspect
799 | except Exception as ex:
800 | print('inspect', ex)
801 |
802 | try:
803 | import site
804 | except Exception as ex:
805 | print('site', ex)
806 |
807 | try:
808 | import fpectl
809 | except Exception as ex:
810 | print('fpectl', ex)
811 |
812 | try:
813 | import code
814 | except Exception as ex:
815 | print('code', ex)
816 |
817 | try:
818 | import codeop
819 | except Exception as ex:
820 | print('codeop', ex)
821 |
822 | try:
823 | import zipimport
824 | except Exception as ex:
825 | print('zipimport', ex)
826 |
827 | try:
828 | import pkgutil
829 | except Exception as ex:
830 | print('pkgutil', ex)
831 |
832 | try:
833 | import modulefinder
834 | except Exception as ex:
835 | print('modulefinder', ex)
836 |
837 | try:
838 | import runpy
839 | except Exception as ex:
840 | print('runpy', ex)
841 |
842 | try:
843 | import importlib
844 | except Exception as ex:
845 | print('importlib', ex)
846 |
847 | try:
848 | import parser
849 | except Exception as ex:
850 | print('parser', ex)
851 |
852 | try:
853 | import ast
854 | except Exception as ex:
855 | print('ast', ex)
856 |
857 | try:
858 | import symtable
859 | except Exception as ex:
860 | print('symtable', ex)
861 |
862 | try:
863 | import symbol
864 | except Exception as ex:
865 | print('symbol', ex)
866 |
867 | try:
868 | import token
869 | except Exception as ex:
870 | print('token', ex)
871 |
872 | try:
873 | import keyword
874 | except Exception as ex:
875 | print('keyword', ex)
876 |
877 | try:
878 | import tokenize
879 | except Exception as ex:
880 | print('tokenize', ex)
881 |
882 | try:
883 | import tabnanny
884 | except Exception as ex:
885 | print('tabnanny', ex)
886 |
887 | try:
888 | import pyclbr
889 | except Exception as ex:
890 | print('pyclbr', ex)
891 |
892 | try:
893 | import py_compile
894 | except Exception as ex:
895 | print('py_compile', ex)
896 |
897 | try:
898 | import compileall
899 | except Exception as ex:
900 | print('compileall', ex)
901 |
902 | try:
903 | import dis
904 | except Exception as ex:
905 | print('dis', ex)
906 |
907 | try:
908 | import pickletools
909 | except Exception as ex:
910 | print('pickletools', ex)
911 |
912 | try:
913 | import formatter
914 | except Exception as ex:
915 | print('formatter', ex)
916 |
917 | try:
918 | import msilib
919 | except Exception as ex:
920 | print('msilib', ex)
921 |
922 | try:
923 | import msvcrt
924 | except Exception as ex:
925 | print('msvcrt', ex)
926 |
927 | try:
928 | import winreg
929 | except Exception as ex:
930 | print('winreg', ex)
931 |
932 | try:
933 | import winsound
934 | except Exception as ex:
935 | print('winsound', ex)
936 |
937 | try:
938 | import posix
939 | except Exception as ex:
940 | print('posix', ex)
941 |
942 | try:
943 | import pwd
944 | except Exception as ex:
945 | print('pwd', ex)
946 |
947 | try:
948 | import spwd
949 | except Exception as ex:
950 | print('spwd', ex)
951 |
952 | try:
953 | import grp
954 | except Exception as ex:
955 | print('grp', ex)
956 |
957 | try:
958 | import crypt
959 | except Exception as ex:
960 | print('crypt', ex)
961 |
962 | try:
963 | import termios
964 | except Exception as ex:
965 | print('termios', ex)
966 |
967 | try:
968 | import tty
969 | except Exception as ex:
970 | print('tty', ex)
971 |
972 | try:
973 | import pty
974 | except Exception as ex:
975 | print('pty', ex)
976 |
977 | try:
978 | import fcntl
979 | except Exception as ex:
980 | print('fcntl', ex)
981 |
982 | try:
983 | import fcntl
984 | except Exception as ex:
985 | print('fcntl', ex)
986 |
987 | try:
988 | import ioctl
989 | except Exception as ex:
990 | print('ioctl', ex)
991 |
992 | try:
993 | import pipes
994 | except Exception as ex:
995 | print('pipes', ex)
996 |
997 | try:
998 | import resource
999 | except Exception as ex:
1000 | print('resource', ex)
1001 |
1002 | try:
1003 | import nis
1004 | except Exception as ex:
1005 | print('nis', ex)
1006 |
1007 | try:
1008 | import syslog
1009 | except Exception as ex:
1010 | print('syslog', ex)
1011 |
1012 | try:
1013 | import optparse
1014 | except Exception as ex:
1015 | print('optparse', ex)
1016 |
1017 | try:
1018 | import imp
1019 | except Exception as ex:
1020 | print('imp', ex)
1021 |
--------------------------------------------------------------------------------