MCPcopy Index your code
hub / github.com/pyload/pyload / periodical_task

Method periodical_task

module/plugins/hooks/ExternalScripts.py:66–109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

64 self.log_debug(e, trace=True)
65
66 def periodical_task(self):
67 self.make_folders()
68
69 for folder in self.folders:
70 scripts = []
71 dirname = os.path.join("scripts", folder)
72
73 if folder not in self.scripts:
74 self.scripts[folder] = []
75
76 if os.path.isdir(dirname):
77 for entry in os.listdir(dirname):
78 file = os.path.join(dirname, entry)
79
80 if not os.path.isfile(file):
81 continue
82
83 if file[0] in ("#", "_") or file.endswith(
84 "~") or file.endswith(".swp"):
85 continue
86
87 if not os.access(file, os.X_OK):
88 self.log_warning(
89 _("Script `%s` is not executable") % entry)
90
91 scripts.append(file)
92
93 new_scripts = [
94 _s for _s in scripts if _s not in self.scripts[folder]]
95
96 if new_scripts:
97 script_names = map(os.path.basename, new_scripts)
98 self.log_info(_("Activated scripts in folder `%s`: %s")
99 % (folder, ", ".join(script_names)))
100
101 removed_scripts = [
102 _s for _s in self.scripts[folder] if _s not in scripts]
103
104 if removed_scripts:
105 script_names = map(os.path.basename, removed_scripts)
106 self.log_info(_("Deactivated scripts in folder `%s`: %s")
107 % (folder, ", ".join(script_names)))
108
109 self.scripts[folder] = scripts
110
111 def call_cmd(self, command, *args, **kwargs):
112 call = map(fs_encode, [command] + list(args))

Callers 1

initMethod · 0.95

Calls 6

make_foldersMethod · 0.95
joinMethod · 0.80
log_warningMethod · 0.80
log_infoMethod · 0.80
_Function · 0.50
appendMethod · 0.45

Tested by

no test coverage detected