Mpall - Hot!
def parse_replacements(self) -> List[Dict[str, str]]: """Parse replacement arguments into list of parameter dictionaries.""" replacements = [] if self.args.replace_file: with open(self.args.replace_file, 'r') as f: for line in f: line = line.strip() if not line or line.startswith('#'): continue parts = line.split() if len(parts) < 2: self.logger.warning(f"Skipping invalid line: line") continue # Format: key1=val1 key2=val2 ... replacement = {} for part in parts: if '=' in part: k, v = part.split('=', 1) replacement[k] = v if replacement: replacements.append(replacement) elif self.args.replace: # Format: key1=val1,key2=val2 or multiple -r flags for rep in self.args.replace: rep_dict = {} for pair in rep.split(','): if '=' in pair: k, v = pair.split('=', 1) rep_dict[k] = v replacements.append(rep_dict) else: # Single run with no replacements replacements.append({}) return replacements
class Logger: """Unified logging handler with file and console output.""" def (self, log_file: Optional[str] = None, verbose: bool = False): self.logger = logging.getLogger("mpall") self.logger.setLevel(logging.DEBUG if verbose else logging.INFO) def parse_replacements(self) ->
app = Mpall(args) sys.exit(app.run()) if == " main ": main() README.md # mpall - Multi-Process All-in-One Launcher Run commands in parallel across multiple processes with logging, retries, timeouts, and aggregated output. Installation chmod +x mpall.py sudo ln -s $(pwd)/mpall.py /usr/local/bin/mpall </code></pre> <h2>Usage</h2> <pre><code class="language-bash">mpall -c "command placeholder" -r key=value -w 4 </code></pre> <h2>Features</h2> <ul> <li>✅ <strong>Parallel execution</strong> (configurable worker count)</li> <li>✅ <strong>Placeholder replacement</strong> (<code>var</code> in commands)</li> <li>✅ <strong>Retry on failure</strong> (per task)</li> <li>✅ <strong>Timeout protection</strong> (per command)</li> <li>✅ <strong>JSON output</strong> for programmatic analysis</li> <li>✅ <strong>Signal handling</strong> (graceful Ctrl+C)</li> <li>✅ <strong>Logging</strong> (file + console)</li> <li>✅ <strong>Environment variables</strong> injection</li> </ul> <h2>Examples</h2> <h3>Basic parallel runs</h3> <pre><code class="language-bash">mpall -c "echo Hello" -r {} -w 10 </code></pre> <h3>Variable replacement</h3> <pre><code class="language-bash">mpall -c "curl url" -r url=https://api.example.com,method=GET </code></pre> <h3>Multiple replacements</h3> <pre><code class="language-bash">mpall -c "process.py input output" \ -r input=file1.txt,output=out1.txt \ -r input=file2.txt,output=out2.txt </code></pre> <h3>From file</h3> <pre><code class="language-bash">cat > tasks.txt <<EOF input=in1.txt,output=out1.txt input=in2.txt,output=out2.txt EOF v = part.split('='
def debug(self, msg): self.logger.debug(msg) def info(self, msg): self.logger.info(msg) def warning(self, msg): self.logger.warning(msg) def error(self, msg): self.logger.error(msg) class CommandExecutor: """Executes shell commands with timeout and environment support.""" '): if '=' in pair: k
def _save_summary_text(self): """Save summary to text file.""" with open(self.args.output_summary, 'w') as f: f.write("MPALL EXECUTION SUMMARY\n") f.write("=" * 50 + "\n") for r in self.results: f.write(f"Task r.task_id: 'SUCCESS' if r.success else 'FAIL'\n") if not r.success: f.write(f" Error: r.stderr[:200]\n") def main(): parser = argparse.ArgumentParser( description="mpall - Run commands across multiple parallel processes", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=""" Examples: mpall -w 2 -c echo hello -r {} Replace placeholders mpall -c "echo name is age" -r name=alice,age=30 -r name=bob,age=25 Use replacement file mpall -c "process_file.py input output" -f replacements.txt -w 4 With retries and timeout mpall -c "curl url" -r url=http://example.com -t 30 --retries 3 Save results mpall -c "test.sh param" -r param=1 -o results.json --summary summary.txt """ )
parser.add_argument( "-r", "--replace", action="append", default=[], help="Replacements as key1=val1,key2=val2 (can specify multiple times)" )