Changeset aa734cb0 in rattail
- Timestamp:
- 11/20/2022 03:30:25 PM (2 months ago)
- Branches:
- master
- Children:
- 3e17fc4
- Parents:
- bea5278
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
rattail/luigi/handler.py
rbea5278 raa734cb0 148 148 return task 149 149 150 def launch_overnight_task(self, task, date, **kwargs): 150 def launch_overnight_task(self, task, date, 151 email_if_empty=True, 152 email_key=None, 153 with_at=True, 154 dry_run=False, 155 **kwargs): 156 """ 157 Launch the given overnight task, to run for the given date. 158 159 :param task: An overnight task info dict, e.g. as obtained 160 from :meth:`get_overnight_task()`. 161 162 :param date: Date for which task should run. 163 164 :param email_if_empty: If true (the default), then email will 165 be sent when the task command completes, even if it 166 produces no output. If false, then email is sent only if 167 the command produces output. 168 169 :param email_key: Optional config key for email settings to be 170 used in determining recipients etc. 171 172 :param with_at: If true (currently the default), the task 173 should be scheduled via the ``at`` command, to begin within 174 the next minute. (This lets process control return 175 immediately to the caller.) If false, the task will run 176 in-process, and so will begin immediately, but caller must 177 wait for it to complete. You are encouraged to specify the 178 value you want here, as the default may change in the 179 future. 180 181 :param dry_run: If true, log the final command for the task 182 but do not actually run it. 183 """ 151 184 appdir = self.config.appdir() 152 185 … … 161 194 '--no-versioning', 162 195 'run-n-mail', 163 '-S', "Overnight for {}: {}".format(date, task[' description']),196 '-S', "Overnight for {}: {}".format(date, task['key']), 164 197 cmd] 165 166 cmd = ['echo', shlex_join(cmd)] 167 cmd = shlex_join(cmd) 168 169 cmd = "{} | at 'now + 1 minute'".format(cmd) 198 if email_key: 199 cmd.extend(['--key', email_key]) 200 if not email_if_empty: 201 cmd.append('--skip-if-empty') 202 203 if with_at: 204 cmd = ['echo', shlex_join(cmd)] 205 cmd = shlex_join(cmd) 206 cmd = "{} | at 'now + 1 minute'".format(cmd) 207 208 # log final command 209 log.debug("launching command in subprocess: %s", cmd) 210 if dry_run: 211 log.debug("dry-run mode, so aborting") 212 return 170 213 171 214 # run command in subprocess 172 log.debug("launching command in subprocess: %s", cmd)173 215 try: 174 subprocess.check_output(cmd, shell= True, env=env,216 subprocess.check_output(cmd, shell=with_at, env=env, 175 217 stderr=subprocess.PIPE) 176 218 except subprocess.CalledProcessError as error: -
setup.py
rbea5278 raa734cb0 237 237 'make-uuid = rattail.commands.core:MakeUUID', 238 238 'mysql-chars = rattail.commands.mysql:MysqlChars', 239 'overnight = rattail.commands.luigi:Overnight', 239 240 'populate-batch = rattail.commands.batch:PopulateBatch', 240 241 'problems = rattail.commands.problems:Problems',
Note: See TracChangeset
for help on using the changeset viewer.