diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-12 08:10:42 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-12 08:24:06 +0200 |
commit | 466fcd268e53743ca7414f1fe969a74cd0ac1ee1 (patch) | |
tree | 18056390e7f507c1f40b38edfaa4c218b840f0e7 | |
parent | 2a562fd5a7d935d3743f6746927236b40f891a5c (diff) | |
download | extrautils-466fcd268e53743ca7414f1fe969a74cd0ac1ee1.tar.gz |
drop old crap
-rwxr-xr-x | assert | 89 | ||||
-rw-r--r-- | assert.1 | 34 | ||||
-rwxr-xr-x | benchmark-cmd | 170 | ||||
-rw-r--r-- | benchmark-cmd.1.in | 42 | ||||
-rwxr-xr-x | build-deb-from-git | 10 | ||||
-rw-r--r-- | corrupt.1 | 32 | ||||
-rw-r--r-- | corrupt.c | 177 | ||||
-rwxr-xr-x | fix-shebang | 54 | ||||
-rw-r--r-- | fix-shebang.1 | 45 | ||||
-rwxr-xr-x | humanify | 90 | ||||
-rw-r--r-- | humanify.1 | 44 | ||||
-rw-r--r-- | isascii.1 | 47 | ||||
-rw-r--r-- | isascii.c | 141 | ||||
-rwxr-xr-x | keepalive | 17 | ||||
-rwxr-xr-x | mbox2maildir | 41 | ||||
-rwxr-xr-x | minimify | 71 | ||||
-rw-r--r-- | minimify.1 | 33 | ||||
-rwxr-xr-x | musictomp3 | 258 | ||||
-rw-r--r-- | musictomp3.1 | 43 | ||||
-rwxr-xr-x | os-rchelper | 110 | ||||
-rwxr-xr-x | progress-du | 60 | ||||
-rw-r--r-- | progress-du.1 | 27 | ||||
-rw-r--r-- | project.meta | 4 | ||||
-rwxr-xr-x | runql | 14 | ||||
-rwxr-xr-x | setuppy-debian-versions-match | 29 | ||||
-rw-r--r-- | setuppy-debian-versions-match.1 | 33 | ||||
-rwxr-xr-x | splitmboxdaily | 81 | ||||
-rw-r--r-- | splitmboxdaily.1 | 26 | ||||
-rwxr-xr-x | sshvia | 219 | ||||
-rwxr-xr-x | test-flacs | 60 | ||||
-rw-r--r-- | test-flacs.1 | 25 | ||||
-rwxr-xr-x | unpack-debian-sources | 104 | ||||
-rw-r--r-- | unpack-debian-sources.1 | 61 | ||||
-rwxr-xr-x | viewprof | 34 | ||||
-rw-r--r-- | viewprof.1 | 25 | ||||
-rwxr-xr-x | whatismyip | 4 | ||||
-rwxr-xr-x | with | 35 |
37 files changed, 0 insertions, 2389 deletions
@@ -1,89 +0,0 @@ -#!/usr/bin/python - - -import gnomevfs -import optparse -import os -import subprocess -import sys - - -def setup_option_parser(): - parser = optparse.OptionParser() - - parser.add_option("--file", metavar="FILE", - help="Report FILE as being failing the assertion.") - - return parser - - -def equal(options, args): - return args[0] == args[1], "%s != %s" % (repr(args[0]), repr(args[1])) - - -def mime_type_is(options, args): - wanted_type = args[0] - args = args[1:] - for arg in args: - uri = gnomevfs.get_uri_from_local_path(os.path.abspath(arg)) - actual_type = gnomevfs.get_mime_type(uri) - if actual_type != wanted_type: - options.file = arg - return False, "%s != %s" % (wanted_type, actual_type) - return True, None - - -def file_type_is(options, args): - wanted_type = args[0] - filenames = args[1:] - for filename in filenames: - p = subprocess.Popen(["file", "-0", filename], stdout=subprocess.PIPE) - stdout, stderr = p.communicate() - if p.returncode == 0: - filename, actual_type = stdout.split("\0") - actual_type = actual_type.strip() - if actual_type != wanted_type: - return False, "%s != %s" % (wanted_type, actual_type) - return True, None - - -def main(): - parser = setup_option_parser() - options, args = parser.parse_args() - - opers = { - "equal": (2, 2, equal), - "file-type-is": (2, None, file_type_is), - "mime-type-is": (2, None, mime_type_is), - } - - if not args: - raise Exception("No operation on command line.") - elif args[0] in opers: - name = args[0] - args = args[1:] - min_count, max_count, func = opers[name] - if (len(args) < min_count or - (max_count is not None and len(args) > max_count)): - raise Exception("Operation %s must have %d..%d " - "arguments (got %d)." % - (name, min_count, max_count or "infinity", - len(args))) - ok, msg = func(options, args) - if not ok: - parts = [] - if options.file: - parts.append("%s: " % options.file) - parts.append("Assertion failed: ") - parts.append(msg or " ".join(sys.argv[1:])) - raise Exception("".join(parts)) - else: - raise Exception("Unknown operation '%s'." % args[0]) - - -if __name__ == "__main__": - try: - main() - except Exception, e: - sys.stderr.write("%s\n" % str(e)) - sys.exit(1) diff --git a/assert.1 b/assert.1 deleted file mode 100644 index c555482..0000000 --- a/assert.1 +++ /dev/null @@ -1,34 +0,0 @@ -.\" assert.1 - manual page for the assert command -.\" Copyright (C) 2009 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH ASSERT 1 -.SH NAME -assert \- make sure given conditions are true -.SH SYNOPSIS -.B assert -.RI [ --file =\fIFILE\fR] -.SH DESCRIPTION -.B assert -checks that specific conditions are true. -At the moment, it can check that a file has a given type (MIME or file(1)). -.SH EXAMPLE -The following command checks that the file NEWS has the MIME type text/plain. -.sp 1 -.ti +4 -.nf -assert mime-type-is text/plain NEWS -.fi - diff --git a/benchmark-cmd b/benchmark-cmd deleted file mode 100755 index 95fe67d..0000000 --- a/benchmark-cmd +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/python3 - -import cliapp -import os -import tempfile - - -class Table(object): - - """Represent tabular data for formatting purposes.""" - - sep = " " - - def __init__(self): - self.caption = None - self.columns = [] - self.rows = [] - - def add_column(self, heading1, heading2, format, left=False): - self.columns.append((heading1, heading2, format, left)) - - def add_row(self, data): - assert len(data) == len(self.columns) - self.rows.append(data) - - def write_plaintext(self, f): - if self.caption: - f.write("%s\n%s\n\n" % (self.caption, "-" * len(self.caption))) - - cells = [] - cells.append([h1 for h1, h2, format, left in self.columns]) - cells.append([h2 for h1, h2, format, left in self.columns]) - for row in self.rows: - cells.append( - [ - self.format_cell(row[i], self.columns[i][2]) - for i in range(len(self.columns)) - ] - ) - - widths = self.compute_column_widths(cells) - - f.write("%s\n" % self.format_headings(widths, 0)) - f.write("%s\n" % self.format_headings(widths, 1)) - for row in self.rows: - f.write("%s\n" % self.format_row(row, widths)) - - def format_cell(self, data, format): - return format % data - - def compute_column_widths(self, cells): - widths = [0] * len(self.columns) - for row in cells: - for i, data in enumerate(row): - widths[i] = max(widths[i], len(data)) - return widths - - def format_headings(self, widths, which): - headings = [ - self.pad(widths[i], self.columns[i][which], self.columns[i][3]) - for i in range(len(widths)) - ] - return self.sep.join(headings) - - def format_row(self, row, widths): - def cell(i): - h1, h2, format, left = self.columns[i] - return self.pad(widths[i], format % row[i], left) - - cells = [cell(i) for i in range(len(widths))] - return self.sep.join(cells) - - def pad(self, width, text, left): - if left: - return "%-*s" % (width, text) - else: - return "%*s" % (width, text) - - -class Benchmarker(cliapp.Application): - def add_settings(self): - self.settings.string_list(["command"], "command to benchmark") - self.settings.string_list(["verify"], "command for verifying result") - self.settings.string_list(["setup"], "command for setup") - self.settings.string_list(["cleanup"], "command for cleanup") - self.settings.boolean(["setup-once"], "do setups only once") - self.settings.boolean(["cleanup-once"], "do cleanups only once") - self.settings.boolean(["verbose"], "show commands and their output") - - def process_args(self, args): - results = Table() - results.add_column("user", "(s)", "%.1f") - results.add_column("system", "(s)", "%.1f") - results.add_column("real", "(s)", "%.1f") - results.add_column("max RSS", "(KiB)", "%d") - results.add_column("cmd", "", "%-0s", left=True) - - commands = self.settings["command"] - if commands and self.settings["setup-once"]: - self.setup() - for cmd in commands: - if not self.settings["setup-once"]: - self.setup() - numbers = self.measure_cmd(cmd) - self.verify() - results.add_row(numbers + (cmd,)) - if not self.settings["cleanup-once"]: - self.cleanup() - if self.settings["verbose"]: - self.output.write("\n") - if commands and self.settings["cleanup-once"]: - self.cleanup() - - results.write_plaintext(self.output) - - def setup(self): - self.run_shell(self.settings["setup"]) - - def cleanup(self): - self.run_shell(self.settings["cleanup"]) - - def verify(self): - self.run_shell(self.settings["verify"]) - - def run_shell(self, cmds): - for cmd in cmds: - if self.settings["verbose"]: - self.output.write("COMMAND: %s\n" % cmd) - out = self.runcmd(["sh", "-c", cmd]) - if self.settings["verbose"]: - self.output.write(out) - - def measure_cmd(self, cmd): - fd, timings = tempfile.mkstemp() - time_argv = [ - "/usr/bin/time", - "-o", - timings, - "--format", - "%U\n%S\n%e\n%M\n%e", - "--", - "sh", - "-c", - cmd, - ] - - if self.settings["verbose"]: - self.output.write("MEASURE: %s\n" % cmd) - out = self.runcmd(time_argv) - if self.settings["verbose"]: - self.output.write(out) - - data = [] - while True: - datum = os.read(fd, 1024 ** 2) - if not datum: - break - data.append(datum) - os.close(fd) - data = "".join(data) - - fields = [float(x) for x in data.splitlines()] - user = fields[0] - system = fields[1] - real = fields[2] - maxrss = fields[3] - return user, system, real, maxrss - - -Benchmarker().run() diff --git a/benchmark-cmd.1.in b/benchmark-cmd.1.in deleted file mode 100644 index 275dc0c..0000000 --- a/benchmark-cmd.1.in +++ /dev/null @@ -1,42 +0,0 @@ -.\" Copyright 2011 Lars Wirzenius <liw@liw.fi> -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH BENCHMARK-CMD 1 -.SH NAME -benchmark-cmd \- benchmark shell commands -.SH SYNOPSIS -.SH DESCRIPTION -.B benchmark-cmd -benchmarks one or more Unix shell commands. -It runs some setup commands, -then the actual command, -and then some cleanup commands, -and can do this for several actual commands. -It then reports the timing results for each actual command. -.SH OPTIONS -.SH EXAMPLE -To see whether -.BR ls (1) -or -.BR find (1) -is faster: -.IP -.nf -$ benchmark-cmd --command='ls -lAR $HOME' \\ - --command='find $HOME -ls' -real user system max RSS elapsed cmd - (s) (s) (s) (KiB) (s) - 0.4 1.0 1.4 8608 1.4 ls -lAR $HOME - 0.4 0.4 0.8 8400 0.8 find $HOME -ls diff --git a/build-deb-from-git b/build-deb-from-git deleted file mode 100755 index 91f4345..0000000 --- a/build-deb-from-git +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -set -eu - -pkg="$(dpkg-parsechangelog -S Source)" -version="$(dpkg-parsechangelog -S Version)" -upversion="$(echo "$version" | sed 's/-.*//')" -origtgz="../${pkg}_${upversion}.orig.tar.xz" -git archive HEAD | xz > "$origtgz" -debuild -us -uc diff --git a/corrupt.1 b/corrupt.1 deleted file mode 100644 index d37aea7..0000000 --- a/corrupt.1 +++ /dev/null @@ -1,32 +0,0 @@ -.\" corrupt.1 - manual page for the corrupt command -.\" Copyright (C) 2009 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH CORRUPT 1 -.SH NAME -corrupt \- modify files by randomly changing bits -.SH SYNOPSIS -.BR corrupt -[\fB\-n\fR \fIBITS\fR] -[\fB\-\-bits\fR \fIBITS\fR] -.IR file ... -.SH DESCRIPTION -.B corrupt -modifies files by toggling a randomly chosen bit. -.SH OPTIONS -.TP -.BR \-n ", " \-\-bits =\fIBITS\fR -Set the number of bits to modify. -Default is one bit. diff --git a/corrupt.c b/corrupt.c deleted file mode 100644 index 0d29453..0000000 --- a/corrupt.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2009 Lars Wirzenius - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#define _LARGEFILE64_SOURCE -#define _GNU_SOURCE - -#include <errno.h> -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <getopt.h> - - -/* Number of bits to corrupt. */ -static int num_bits = 1; - - -/* Choose a random integer in [0..n-1]. */ -static long choose(long n) -{ - if (n == 0) - return 0; - - long buckets = (RAND_MAX + 1L) / n; - long max = buckets * n; - long r; - - do { - r = random(); - } while (r >= max); - return r / buckets; -} - - -static int seek(const char *filename, int fd, off_t offset) -{ - if (lseek(fd, offset, SEEK_SET) == (off_t) -1) { - fprintf(stderr, "Can't seek in %s: %s", filename, strerror(errno)); - return -1; - } - return 0; -} - - -static int corrupt_one_bit(const char *filename, int fd, struct stat st) -{ - long offset; - long bit; - unsigned char byte; - - offset = choose(st.st_size); - bit = choose(CHAR_BIT); - - if (seek(filename, fd, offset) == -1) - return -1; - if (read(fd, &byte, 1) == -1) { - fprintf(stderr, "Can't read %s: %s", filename, strerror(errno)); - return -1; - } - - /* This is where we toggle the bit. */ - unsigned mask = 1 << bit; // All zeroes, except for the interesting bit. - unsigned interesting = byte & mask; // Only the interesting bit can be 1. - unsigned toggled = interesting ^ mask; // Interesting bit has been toggled. - unsigned others = byte & (~mask); // Interesting bit is 0. - byte = others | toggled; - - /* Now write it back. */ - if (seek(filename, fd, offset) == -1) - return -1; - if (write(fd, &byte, 1) != 1) { - fprintf(stderr, "Can't write %s: %s", filename, strerror(errno)); - return -1; - } - - return 0; -} - - -static int corrupt(const char *filename) -{ - int fd; - struct stat st; - - fd = open(filename, O_RDWR | O_LARGEFILE); - if (fd == -1) { - fprintf(stderr, "Can't open %s: %s\n", filename, strerror(errno)); - return -1; - } - - if (fstat(fd, &st) == -1) { - fprintf(stderr, "Can't find length of %s: %s", filename, - strerror(errno)); - return -1; - } - - for (int i = 0; i < num_bits; ++i) - if (corrupt_one_bit(filename, fd, st) == -1) - return -1; - - if (close(fd) == -1) { - fprintf(stderr, "Can't close %s: %s", filename, strerror(errno)); - return -1; - } - - return 0; -} - - -static int parse_args(int argc, char **argv) -{ - const char optstring[] = "n:"; - const struct option longopts[] = { - { "bits", required_argument, NULL, 'n' }, - { 0 }, - }; - char *endptr; - - for (;;) { - int opt = getopt_long(argc, argv, optstring, longopts, NULL); - switch (opt) { - case -1: - return optind; - - case 'n': - num_bits = strtol(optarg, &endptr, 10); - if (*endptr != '\0') { - fprintf(stderr, "Invalid number of bits: %s\n", optarg); - exit(1); - } - break; - - default: - case '?': - exit(1); - } - } -} - - -int main(int argc, char **argv) -{ - int exit_code; - int i; - - i = parse_args(argc, argv); - if (i == -1) - return 1; - - srandom(time(NULL) + getpid()); - exit_code = 0; - for (; i < argc; ++i) - if (corrupt(argv[i]) == -1) - exit_code = 1; - return exit_code; -} diff --git a/fix-shebang b/fix-shebang deleted file mode 100755 index 8478cd2..0000000 --- a/fix-shebang +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Copyright 2011 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -import cliapp -import os -import tempfile - - -class FixShebang(cliapp.Application): - - def add_settings(self): - self.settings.string(['shebang'], 'interpreter path and args') - - def process_input(self, arg): - name = self.create_tempfile_for(arg) - temp = open(name, 'w') - shebang = self.settings['shebang'] - if not shebang: - raise Exception('You must specify an interpreter with --shebang') - if not shebang.startswith('#!'): - shebang = '#!%s' % shebang - temp.write('%s\n' % shebang) - f = open(arg) - line1 = f.readline() - if line1 and not line1.startswith('#!'): - temp.write(line1) - for line in f: - temp.write(line) - f.close() - temp.close() - os.rename(name, arg) - - def create_tempfile_for(self, filename): - fd, name = tempfile.mkstemp(dir=os.path.dirname(filename)) - os.close(fd) - return name - - -if __name__ == '__main__': - FixShebang().run() diff --git a/fix-shebang.1 b/fix-shebang.1 deleted file mode 100644 index 56fc918..0000000 --- a/fix-shebang.1 +++ /dev/null @@ -1,45 +0,0 @@ -.\" Copyright 2011 Lars Wirzenius <liw@liw.fi> -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH FIX-SHEBANG 1 -.SH NAME -fix-shebang \- set the #! line for scripts -.SH SYNOPSIS -.B fix-shebang -.RB [ \-\-shebang\fR=\fIinterp ] -.IR file ... -.SH DESCRIPTION -.B fix-shebang -sets the interpreter or -.I shebang -line for script files. -This is the line that starts with -.B #! -at the beginning of on the first line. -For example, typically a shell script would be -.sp 1 -.RS -#!/bin/sh -.RE -.sp 1 -For other interpreters, such as Python or Perl or Ruby, -it may be necessary to change the interpreter on different systems. -.B fix-shebang -makes that easy. -.SH OPTIONS -.TP -.BR \-\-shebang =\fIinterpreter -Set the interpreter to be -.BR #!\fIinterpreter . diff --git a/humanify b/humanify deleted file mode 100755 index 32454fc..0000000 --- a/humanify +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python -# Copyright 2011 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -import cliapp -import sys - - -class Humanify(cliapp.Application): - - iso_prefixes = [ - (1000**8, 'Y'), - (1000**7, 'Z'), - (1000**6, 'E'), - (1000**5, 'P'), - (1000**4, 'T'), - (1000**3, 'G'), - (1000**2, 'M'), - (1000, 'k'), - (1, ''), - ] - iec_prefixes = [ - (1024**8, 'Yi'), - (1024**7, 'Zi'), - (1024**6, 'Ei'), - (1024**5, 'Pi'), - (1024**4, 'Ti'), - (1024**3, 'Gi'), - (1024**2, 'MI'), - (1024, 'Ki'), - (1, ''), - ] - - def add_settings(self): - self.settings.boolean(['binary', 'iec'], - 'use 10-based, not 2-based prefixes ' - '(ISO vs IEC)') - self.settings.boolean(['bits'], 'inputs give numbers of bits') - - def process_args(self, args): - self.units = self.determine_units() - - if args: - for arg in args: - self.humanify(arg) - else: - for line in sys.stdin: - self.humanify(float(line.strip())) - - def determine_units(self): - if self.settings['binary']: - prefixes = self.iec_prefixes - else: - prefixes = self.iso_prefixes - if self.settings['bits']: - suffix = 'b' - else: - suffix = 'B' - return [(factor, prefix + suffix) for factor, prefix in prefixes] - - def humanify(self, arg): - self.output.write('%s\n' % self._humanify(float(arg), self.units)) - - def _humanify(self, value, units): - assert units - if value >= units[0][0]: - return '%.0f %s' % (round(float(value) / units[0][0]), - units[0][1]) - for factor, unit in units: - size = float(value) / float(factor) - if 1 <= size < 1000: - return '%.0f %s' % (round(size), unit) - return '%.0f %s' % (round(float(value) / units[-1][0]), units[-1][1]) - - -if __name__ == '__main__': - Humanify().run() diff --git a/humanify.1 b/humanify.1 deleted file mode 100644 index dcb80fb..0000000 --- a/humanify.1 +++ /dev/null @@ -1,44 +0,0 @@ -.\" Copyright 2011 Lars Wirzenius <liw@liw.fi> -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH HUMANIFY 1 -.SH NAME -humanify \- format bit- and byte-sizes into human-readable form -.SH SYNOPSIS -.B humanify -.RB [ \-\-binary ] -.RI [ size ...] -.SH DESCRIPTION -.B humanify -formats in human-readable form data sizes (number of bits or bytes). -For example, -it can turn -.I 1234 -into -.I "1 kB" -or -.IR "1 KiB" . -Sizes are given on the command line, -or one-per line in the standard input. -Sizes are rounded to the nearest integer. -.SH OPTIONS -.TP -.BR \-\-binary -Use 2-based prefixes (from IEC), -rather than 10-based ones (from ISO). -In other words, "kibibyte" instead of "kilobyte". -.TP -.BR \-\-bits -Inputs give number of bits, instead of bytes. diff --git a/isascii.1 b/isascii.1 deleted file mode 100644 index 9a3f51d..0000000 --- a/isascii.1 +++ /dev/null @@ -1,47 +0,0 @@ -.\" isacii.1 - manual page for the isascii command -.\" Copyright (C) 2008 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH ISASCII 1 -.SH NAME -isascii \- verify that input files consist of ASCII characters only -.SH SYNOPSIS -.BR isascii " [" "-hq" "] [" --help "] [" --quiet "]" -.IR file ... -.SH DESCRIPTION -.B isascii -reads through one or more files, and determines if they contain only -ASCII characters. -Input comes from files named on the command line, or from the -standard input if there are no filenames on the command line. -.PP -An ASCII character is any byte with a value of 0 through 127, -inclusive. -.SH OPTIONS -.TP -.BR -h ", " --help -Write out a short usage message. -.TP -.BR -q ", " --quiet -Do not write any output except error messages. -Indicate ASCII/not-ASCII status only via the exit code. -.SH "EXIT STATUS" -.B isascii -returns an exit code of 0 if all input files (or standard input) consisted -only of ASCII characters. -It returns a non-zero error code if there were errors or at least one of -the inputs was not pure ASCII. -.SH "SEE ALSO" -.BR isutf8 (1). diff --git a/isascii.c b/isascii.c deleted file mode 100644 index 6294c01..0000000 --- a/isascii.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * isascii - verify that input files consist of ASCII characters only - * Copyright (C) 2007 Lars Wirzenius <liw@iki.fi> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#define _BSD_SOURCE /* For isascii(3). */ - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <getopt.h> - -#include <ctype.h> - - -#define VERSION "1.0" - - -/* - * Code to indicate an invalid UTF8 character. - */ -enum { INVALID_CHAR = 0xffffffff }; - - -/* - * Determine if the contents of an open file form a valid ASCII byte stream. - */ -static int is_ascii_byte_stream(FILE *file, char *filename, int quiet) { - int c; - unsigned long line, col; - - line = 1; - col = 1; - - for (;;) { - c = getc(file); - - if (c == EOF) - break; - else if (c == '\n') { - ++line; - col = 1; - } else if (isascii(c)) { - ++col; - } else - goto error; - } - - return 1; - -error: - if (!quiet) { - printf("%s: line %lu, char %lu: invalid ASCII code: 0x%02x\n", - filename, line, col, c); - } - return 0; -} - - -static void usage(const char *program_name) { - printf("Usage: %s [-hq] [--help] [--quiet] [file ...]\n", - program_name); - printf("Check whether input files are valid ASCII.\n"); - printf("This is version %s.\n", VERSION); -} - - -int main(int argc, char **argv) { - int i, ok; - FILE *file; - - int quiet; - struct option options[] = { - { "help", no_argument, NULL, 'h' }, - { "quiet", no_argument, &quiet, 1 }, - }; - int opt; - - quiet = 0; - - while ((opt = getopt_long(argc, argv, "hq", options, NULL)) != -1) { - switch (opt) { - case 0: - break; - - case 'h': - usage(argv[0]); - exit(0); - break; - - case 'q': - quiet = 1; - break; - - case '?': - exit(EXIT_FAILURE); - - default: - abort(); - } - } - - if (optind == argc) - ok = is_ascii_byte_stream(stdin, "stdin", quiet); - else { - ok = 1; - for (i = optind; i < argc; ++i) { - file = fopen(argv[i], "r"); - if (file == NULL) { - fprintf(stderr, "isascii: %s: error %d: %s\n", - argv[i], errno, - strerror(errno)); - ok = 0; - } else { - if (!is_ascii_byte_stream(file, argv[i], quiet)) - ok = 0; - (void) fclose(file); - } - } - } - - if (ok) - exit(0); - exit(EXIT_FAILURE); -} diff --git a/keepalive b/keepalive deleted file mode 100755 index f264d26..0000000 --- a/keepalive +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -eu - -while true -do - if ping -c1 -t100 8.8.8.8 > /dev/null 2>&1 - then - sleep 5 - else - echo "No networking. Turning networking off and back on again. $(date)" - nmcli networking off - sleep 2 - nmcli networking on - sleep 20 - fi -done diff --git a/mbox2maildir b/mbox2maildir deleted file mode 100755 index d646cae..0000000 --- a/mbox2maildir +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python -# Copyright 2016 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# =*= License: GPL-3+ =*= - - -import mailbox -import sys - -import ttystatus - - -mbox_filename = sys.argv[1] -maildir_name = sys.argv[2] - -mbox = mailbox.mbox(mbox_filename) -maildir = mailbox.Maildir(maildir_name, factory=None, create=True) - -ts = ttystatus.TerminalStatus(period=0.1) -ts.format('%ElapsedTime() copying message %Counter(msg) of %Integer(msgs)') -ts['msgs'] = len(mbox) - -for msg in mbox: - ts['msg'] = msg - maildir.add(msg) -mbox.close() -maildir.close() -ts.finish() diff --git a/minimify b/minimify deleted file mode 100755 index 36fc829..0000000 --- a/minimify +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/python -# -# minimify -- compress file to smallest size -# Copyright (C) 2009 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -import multiprocessing -import optparse -import os -import subprocess -import tempfile - - -COMPRESSORS = ( - ('gzip', '.gz'), - ('bzip2', '.bz2'), - ('xz', '.xz'), -) - - -def parse_args(): - parser = optparse.OptionParser() - options, filenames = parser.parse_args() - return options, filenames - - -def run_compressor(t): - compressor, filename, suffix, options = t - input_f = file(filename) - fd, name = tempfile.mkstemp(dir=os.path.dirname(filename)) - p = subprocess.Popen([compressor], stdin=input_f, stdout=fd) - p.communicate('') - os.close(fd) - if p.returncode: - raise Exception('Compression program %s failed' % p.returncode) - os.rename(name, filename + suffix) - return os.path.getsize(filename + suffix), filename + suffix - - -def compress(filename, options): - args = [(compressor, filename, suffix, options) - for compressor, suffix in COMPRESSORS] - pool = multiprocessing.Pool() - sizes = sorted(pool.map(run_compressor, args)) - for size, pathname in sizes[1:]: - os.remove(pathname) - return sizes[0] - - -def main(): - options, filenames = parse_args() - for filename in filenames: - size, name = compress(filename, options) - print size, name - - -if __name__ == "__main__": - main() diff --git a/minimify.1 b/minimify.1 deleted file mode 100644 index 79d8fd7..0000000 --- a/minimify.1 +++ /dev/null @@ -1,33 +0,0 @@ -.\" minimify.1 - manual page for the minimify command -.\" Copyright (C) 2009 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH MINIMIFY 1 -.SH NAME -minimify \- compress file to minimal size -.SH SYNOPSIS -.BR minimify -.IR file ... -.SH DESCRIPTION -.B minimify -compresses a file using different compression programs and picks the -smallest output. -Note that this can be extremely slow. -.PP -The following compression programs are supported: -.BR gzip , -.BR bzip2 , -and -.BR xz . diff --git a/musictomp3 b/musictomp3 deleted file mode 100755 index f7efda4..0000000 --- a/musictomp3 +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/python - - -'''Make music available as MP3 files. - -Given a directory tree of music, convert files in FLAC format to -# MP3. The MP3 files will be put in a parallel tree. Existing MP3 -# files will be copied or hard-linked over as well. - -The use case for this is that we collect all our master music files -in a central location, /xxxx/content/music. The music is in either FLAC -format (when ripped from CDs, sometimes when bought as downloads), or -as MP3 format. Many portable devices can only handle MP3, or at least -there's no point in storing huge FLAC files on them. Thus converting -everything to MP3 seems like a reasonable thing to do. - -This script does that. - -Usage: musictomp3 /path/to/master /path/to/output - -A FLAC file (*.flac) will be converted to MP3. An existing MP3 file -will be hard-linked (if possible) or copied to the output directory. -The relative paths beneath the master directory will be kept in the -output directory. - -If an output file already exists, conversion or copying of the input -file will be skipped. Files in the output directory that have no -corresponding input file are deleted. It is thus possible to run this -script from a cron job to make sure the output directory is synced -with the master directory. - -''' - - -import logging -import multiprocessing -import optparse -import os -import Queue -import shutil -import subprocess -import sys -import tempfile - - -def mktemp(filename): - fd, tempname = tempfile.mkstemp(dir=os.path.dirname(filename) or '.') - os.close(fd) - return tempname - - -def mp3_filename(filename): - prefix, ext = os.path.splitext(filename) - return prefix + '.mp3' - - -def make_dirs_for_file(filename): - dirname = os.path.dirname(filename) - try: - os.makedirs(dirname) - except: - pass - - -def convert_to_mp3(input_root, output_root, filename): - input_path = os.path.join(input_root, filename) - outputname = mp3_filename(filename) - output_path = os.path.join(output_root, outputname) - - logging.info('Converting: %s -> %s' % (input_path, output_path)) - - make_dirs_for_file(output_path) - - tempname = mktemp(output_path) - argv = ['gst-launch-0.10', - '-q', - 'filesrc', - 'location=%s' % input_path, - '!', - 'decodebin', - '!', - 'lame', - 'quality=2', - 'vbr=4', - 'vbr-max-bitrate=128', - 'vbr-quality=9', - '!', - 'filesink', - 'location=%s' % tempname] - logging.debug('argv: %s' % argv) - p = subprocess.Popen(argv, stdout=subprocess.PIPE) - p.communicate() - if p.returncode != 0: - raise Exception('gst-launch failed') - - os.rename(tempname, output_path) - - -def hardlink_or_copy(input_root, output_root, filename): - input_path = os.path.join(input_root, filename) - output_path = os.path.join(output_root, filename) - - logging.info('Hardlink or copy: %s -> %s' % (input_path, output_path)) - - make_dirs_for_file(output_path) - - try: - os.link(input_path, output_path) - except OSError, e: - tempname = mktemp(output_path) - shutil.copy(input_path, tempname) - os.rename(tempname, output_path) - - -def remove(root, filename): - pathname = os.path.join(root, filename) - logging.info('Removing %s' % pathname) - os.remove(pathname) - - -def do_job(job_queue, result_queue): - for func, args in iter(job_queue.get, None): - result_queue.put(func(*args)) - - -class ProgressReporter(object): - - def __init__(self): - self.max_width = 79 - self.written = '' - if sys.stdout.isatty(): - self.output = self.real_output - else: - self.output = self.dummy_output - - def dummy_output(self, text): - pass - - def real_output(self, text): - sys.stdout.write('\b \b' * len(self.written)) - text = text[:self.max_width] - sys.stdout.write(text) - sys.stdout.flush() - self.written = text - - def update(self, done, total, msg): - if total > 0: - percent = 100.0 * float(done) / float(total) - else: - percent = 0 - self.output('%.0f%% done %s' % (percent, msg)) - - def notify(self, msg): - self.output('') - sys.stdout.write('%s\n' % msg) - - def finish(self): - self.output('') - - -class MusicToMp3(object): - - def create_option_parser(self): - parser = optparse.OptionParser() - - parser.add_option('--no-act', action='store_true', - help='do not actually convert or modify anything') - - return parser - - def parse_command_line(self): - p = self.create_option_parser() - opts, args = p.parse_args() - if len(args) != 2: - raise Exception('Must give exactly two directories as arguments.') - - if not os.path.isdir(args[0]): - raise Exception('Input directory %s is not a directory.' % args[0]) - if not os.path.isdir(args[1]): - raise Exception('Output directory %s is not a directory.' % - args[1]) - - return opts, args - - def find_files(self, root): - pathnames = set() - for dirname, subdirs, filenames in os.walk(root): - for pathname in [os.path.join(dirname, x) for x in filenames]: - pathname = pathname[len(root + os.sep):] - pathnames.add(pathname) - return pathnames - - def needs_converting(self, filename): - return filename.endswith('.flac') - - def needs_copying(self, filename): - dummy, ext = os.path.splitext(filename) - return ext.lower() in ['.mp3', '.m4a'] - - def run(self): - logging.basicConfig(filename='musictomp3.log', level=logging.DEBUG) - opts, args = self.parse_command_line() - - self.progress = ProgressReporter() - self.progress.update(0, 0, 'Finding files') - - inputs = self.find_files(args[0]) - outputs = self.find_files(args[1]) - - converted = 0 - copied = 0 - ignored = 0 - removed = 0 - - jobs = [] - - for filename in inputs: - basename = os.path.basename(filename) - if self.needs_converting(filename): - output = mp3_filename(filename) - job = (convert_to_mp3, (args[0], args[1], filename)) - elif self.needs_copying(filename): - output = filename - job = (hardlink_or_copy, (args[0], args[1], filename)) - else: - output = None - ignored += 1 - if output is not None: - if not os.path.exists(os.path.join(args[1], output)): - jobs.append(job) - if output in outputs: - outputs.remove(output) - - for filename in outputs: - jobs.append((remove, (args[1], filename))) - - job_queue = multiprocessing.Queue() - result_queue = multiprocessing.Queue() - for job in jobs: - job_queue.put(job) - for i in range(multiprocessing.cpu_count()): - p = multiprocessing.Process(target=do_job, - args=(job_queue, result_queue)) - p.start() - total = len(jobs) - for done in range(total): - result = result_queue.get() - self.progress.update(done + 1, total, 'Processing') - - for i in range(multiprocessing.cpu_count()): - job_queue.put(None) - - self.progress.finish() - - -if __name__ == '__main__': - MusicToMp3().run() - diff --git a/musictomp3.1 b/musictomp3.1 deleted file mode 100644 index a408dab..0000000 --- a/musictomp3.1 +++ /dev/null @@ -1,43 +0,0 @@ -.\" musictomp3.1 - manual page for the musictomp3 command -.\" Copyright (C) 2009 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH MUSICTOMP3 1 -.SH NAME -musictomp3 \- convert FLAC to MP3, etc -.SH SYNOPSIS -.B musictomp3 -.RI [ --no-act ] -.I inputdir -.I outputdir -.SH DESCRIPTION -.B musictomp3 -finds music files (*.flac, *.mp3) in -.I inputdir -and copies it to -.I outputdir -while converting FLAC format files to mp3 format. -Other files are ignored. -The directory tree within the input directory is retained in the -output directory. -.PP -Files in the output directory that do not correspond to one in the -input directory -.BR "are deleted" . -.PP -This program is probably not useful for most people. -.PP -The output format is mp3 so the music files work on devices like the -iPod. diff --git a/os-rchelper b/os-rchelper deleted file mode 100755 index bc41b9d..0000000 --- a/os-rchelper +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python2 -# -# OpenStack allows a client to have multiple "projects". To access the -# OpenStack API, the client side libraries need some environment -# variables set (OS_AUTH_URL, OS_PROJECT_NAME, etc), to tell the -# libraries which OpenStack user and project, etc, are used. (As an -# aside, one of the environment variblaes is OS_PASSWORD, which is a -# bad idea, but we can't help that.) -# -# OpenStack allows you to download shell "rc" scripts that you source -# (". foorc.sh") to set up the environment variables. However, it gets -# a bit tedious to manage several such rc scripts. Also, each script -# wants you to enter the API password manually, which is just nasty. -# -# This is os-rchelper, which improves the situation a bit: -# -# * it reads the environment variables from a YAML file, indexed -# by a project name given on the command line (you'll need to -# download the rc script and copy the values to the config file) -# -# * it reads the password with pass(1) so nothing needs to be typed -# manually (i.e., don't put OS_PASSWORD in the config file) -# -# Additionally, this script unsets any pre-existing OS_* environment -# variables. -# -# To use this helper: -# -# 1. Save API password with pass: -# -# pass insert openstack-foo -# -# You need to have pass and gpg set up for this to work. -# -# 2. Create ~/.config/qvarnlabs/openstack.conf (see example below). Add -# the key openstack-pass-name in addition to the OS_* environment -# variables. Set openstack-pass-name to the key name you gave -# pass (openstack-foo above). -# -# 3. To set up a shell session: -# -# eval `os-rchelper foo` -# -# You may want to define a shell function to make this easier (put it -# in .bashrc or similar file): -# -# osrc() { eval `./os-rchelper "$1"`; } -# -# Example conf file (~/.config/qvarnlabs/openstack.conf): -# -# dev: -# openstack-pass-name: qvarnlabs-nebula-cloud -# OS_AUTH_URL: "https://identity.fi-1.nebulacloud.fi:5000/v3" -# OS_PROJECT_ID: "2603e0bfcf624053945a35afa1730dc8" -# OS_PROJECT_NAME: "QvarnLabs development" -# OS_USER_DOMAIN_NAME: "Default" -# OS_USERNAME: "liw@qvarnlabs.com" -# OS_REGION_NAME: "fi-1" -# OS_INTERFACE: "public" -# OS_IDENTITY_API_VERSION: 3 -# infra: -# openstack-pass-name: qvarnlabs-nebula-cloud -# OS_AUTH_URL: "https://identity.fi-1.nebulacloud.fi:5000/v3" -# OS_PROJECT_ID: "5b0e1abf166442f2967edc5233f2e6a6" -# OS_PROJECT_NAME: "QvarnLabs Infra" -# OS_USER_DOMAIN_NAME: "Default" -# OS_USERNAME: "liw@qvarnlabs.com" -# OS_REGION_NAME: "fi-1" -# OS_INTERFACE: "public" -# OS_IDENTITY_API_VERSION: 3 -# -# See: -# - https://control.nebulacloud.fi/project/access_and_security/ -# for downloading rc files (one per project in OpenStack) from the -# Nebula clou - - -import os -import pipes -import subprocess -import sys - -import yaml - - -def env(name, value): - sys.stdout.write('export {}={};\n'.format(name, pipes.quote(value))) - - -project_name = sys.argv[1] - -filename = os.path.expanduser('~/.config/qvarnlabs/openstack.conf') -with open(filename) as f: - conf = yaml.safe_load(f) - - -keyname = conf[project_name]['openstack-pass-name'] -p = subprocess.Popen(['pass', 'show', keyname], stdout=subprocess.PIPE) -password, stderr = p.communicate('') -password = password.rstrip() - -keys_to_remove = [x for x in os.environ if x.startswith('OS_')] -for key in keys_to_remove: - sys.stdout.write('unset {};\n'.format(key)) - -keys = conf[project_name].keys() -keys.remove('openstack-pass-name') -for key in sorted(keys): - env(key, conf[project_name][key]) -env('OS_PASSWORD', password) diff --git a/progress-du b/progress-du deleted file mode 100755 index 157e849..0000000 --- a/progress-du +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# Copyright 2010 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -import os -import sys -import ttystatus - - -def file_usage(ts, pathname): - st = os.lstat(pathname) - ts['total'] += st.st_blocks * 512 - - -def dir_usage(ts, pathname): - for dirname, subdirs, basenames in os.walk(pathname): - ts['dirname'] = dirname - file_usage(ts, dirname) - subdirs.sort() - basenames.sort() - for basename in basenames: - file_usage(ts, os.path.join(dirname, basename)) - - -def main(): - ts = ttystatus.TerminalStatus() - ts.add(ttystatus.ElapsedTime()) - ts.add(ttystatus.Literal(' ')) - ts.add(ttystatus.ByteSize('total')) - ts.add(ttystatus.Literal(' (')) - ts.add(ttystatus.Counter('dirname')) - ts.add(ttystatus.Literal(' dirs) ')) - ts.add(ttystatus.Pathname('dirname')) - - ts['total'] = 0 - - for name in sys.argv[1:]: - if os.path.isdir(name): - dir_usage(ts, name) - else: - file_usage(ts, name) - - ts.finish() - - -if __name__ == '__main__': - main() diff --git a/progress-du.1 b/progress-du.1 deleted file mode 100644 index a065b8c..0000000 --- a/progress-du.1 +++ /dev/null @@ -1,27 +0,0 @@ -.\" progress-du.1 - manual page for the progress-du command -.\" Copyright (C) 2010 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH PROGRESS-DU 1 -.SH NAME -progress-du \- show disk usage of a directory tree -.SH SYNOPSIS -.B progress-du -.IR directory ... -.SH DESCRIPTION -.B progress-du -computes the size of a directory tree. -It reports progress as it runs, -to make it nicer for the user to wait. diff --git a/project.meta b/project.meta deleted file mode 100644 index 8a81a02..0000000 --- a/project.meta +++ /dev/null @@ -1,4 +0,0 @@ -[config] -upstream-name = extrautils -upstream-version = 1.20120523 -basetgz = /home/pbuilder-tgz/squeeze-amd64-custom.tgz, squeeze:i386:/home/pbuilder-tgz/squeeze-i386-custom.tgz, wheezy:/home/pbuilder-tgz/wheezy-amd64-custom.tgz, wheezy:i386:/home/pbuilder-tgz/wheezy-i386-custom.tgz @@ -1,14 +0,0 @@ -#!/bin/sh - -set -eu - -stack="$1" -playbook="$2" -shift 2 - -subdir="$OS_PROJECT_SHORTNAME" -export PASSWORD_STORE_DIR="$HOME/qvarnlabs/code/qvarnlabs-secrets/$subdir" - -CODE="$HOME/qvarnlabs/code/" - -"$CODE/qvarnlabs-openstack/run-playbook" "$stack" "$playbook" "$@" diff --git a/setuppy-debian-versions-match b/setuppy-debian-versions-match deleted file mode 100755 index 4af4e5c..0000000 --- a/setuppy-debian-versions-match +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# setuppy-debian-versions-match - do setup.py and debian/changelog agree? -# Copyright 2010 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -v1="$(python setup.py --version)" -v2="$(dpkg-parsechangelog | awk '/^Version:/ { print $2 }' | sed 's/-[^-]*$//')" - -if [ "$v1" != "$v2" ] -then - echo "setup.py report version $v1" 1>&2 - echo "debian/changelog reports version $v2" 1>&2 - echo "they do not match!" - exit 1 -fi diff --git a/setuppy-debian-versions-match.1 b/setuppy-debian-versions-match.1 deleted file mode 100644 index 2e21239..0000000 --- a/setuppy-debian-versions-match.1 +++ /dev/null @@ -1,33 +0,0 @@ -.\" Copyright 2010 Lars Wirzenius <liw@liw.fi> -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH SETUPPY-DEBIAN-VERSIONS-MATCH 1 -.SH NAME -setuppy-debian-versions-match \- do setup.py and debian/changelog match? -.SH SYNOPSIS -.B setuppy-debian-versions-match -.SH DESCRIPTION -When making a Debian package out of Python code that uses distutils, -it is good to have -.B setup.py --version -and the -.B debian/changelog -file match as far as version information is concerned. -This utility checks that they do match. -It compares only the upstream portion of the Debian version -(everything before the last dash in the version string). -.SH "EXIT STATUS" -Exit code is 0 (true) if the versions match, -and 1 (false) otherwise. diff --git a/splitmboxdaily b/splitmboxdaily deleted file mode 100755 index d573cae..0000000 --- a/splitmboxdaily +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# splitmboxdaily - split an mbox into new ones, one per day -# Copyright 2008-2010 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -import mailbox, sys, re, time, os - -pat = re.compile(r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), )?" - r" ?(?P<day>\d\d?) " - r"(?P<mon>(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)) " - r"(?P<year>\d\d(\d\d)?) ") - -montab = { - "Jan": "01", - "Feb": "02", - "Mar": "03", - "Apr": "04", - "May": "05", - "Jun": "06", - "Jul": "07", - "Aug": "08", - "Sep": "09", - "Oct": "10", - "Nov": "11", - "Dec": "12", -} - -outbox = {} - -for filename in sys.argv[1:]: - mbox = mailbox.mbox(filename) - count = 0 - start = time.time() - for key in sorted(mbox.keys()): - msg = mbox[key] - m = pat.match(msg["Date"] or "") - if m: - day = "%02d" % int(m.group("day")) - mon = montab[m.group("mon")] - year = m.group("year") - if int(year) < 10: - year = "20" + year - elif 88 <= int(year) < 100: - year = "19" + year - else: - year = "unknown" - mon = "00" - day = "00" - - name = "%s/%s-%s-%s.mbox" % (year, year, mon, day) - if not os.path.isdir("%s" % year): - os.mkdir("%s" % year) - if name not in outbox: - outbox[name] = mailbox.mbox(name) - outbox[name].add(msg) - - count += 1 - if (count % 10) == 0 or count == len(mbox): - sys.stdout.write("\r%5.1f done" % - (100.0 * count/len(mbox))) - duration = (time.time() - start) or 1.0 - sys.stdout.write(" %6.1f msgs/s" % (count/duration)) - sys.stdout.write(" %s" % filename) - sys.stdout.flush() - - print - for box in outbox.values(): - box.close() - outbox = {} diff --git a/splitmboxdaily.1 b/splitmboxdaily.1 deleted file mode 100644 index b5525b8..0000000 --- a/splitmboxdaily.1 +++ /dev/null @@ -1,26 +0,0 @@ -.\" Copyright 2010 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.TH SPLITMBOXDAILY 1 2010-05-04 -.SH NAME -splitmboxdaily \- split a mailbox into smaller ones, one per day -.SH SYNOPSIS -.B splitmboxdaily -.IR mboxfile ... -.SH DESCRIPTION -.B splitmboxdaily -reads one or more mailboxes (standard Unix mbox format), -and writes the mails to a set of new ones. -It will collect all mails for each day into one output mailbox. -It blindly relies on the Date: header to decide the output mailbox. @@ -1,219 +0,0 @@ -#!/usr/bin/python -# -# Summary -# ======= -# -# ssh user1%foo:2222+user2%bar -# -# This logs in a user2@bar via user1@foo (port 2222). All -# authentication happens locally, not on remote hosts. Private keys -# are only locally, not on foo. -# -# Note that port for the last host must be given using ssh -p, not a -# :22 suffix to the host. This is because this script doesn't get -# called in that case and can't handle it, and ssh itself doesn't -# handle it. -# -# Description -# =========== -# -# This is a helper to allow ssh to be used in a "via this host" -# manner. The user runs "ssh foo+bar" and this effectively logs them -# into bar by first logging into foo and running ssh there. -# -# This is useful when bar is not directly accessible from the local -# machine, but foo is. Authentication (ssh private keys, password -# entry) is done on the local machine, even for the login to bar: -# there is no need to, for example, store ssh private keys on foo. -# -# Example use case: one has a set of virtual machines behind a -# firewall or NAT, and only one of them is accessible from anywhere on -# the Internet. This is called a jump host. You're expected to access -# the other hosts via the jumphost. -# -# Setup -# ===== -# -# User needs to setup their ssh on the local host (via ~/.ssh/config) -# to run this when there is a plus sign in the target hostname: -# -# Host *+* -# ProxyCommand $(sshvia %h %p) -# -# Also, this script should be executable and accessible via $PATH, or -# else the config file should use the full path to this script. -# -# There is no need to configure anything on remote hosts, assuming -# they have a working ssh already. -# -# Implementation -# ============== -# -# This program outputs the magic ssh command line to connect to the -# first target on the command line and to forward its stdin, stdout to -# to that host. In other words, given the following command line: -# -# ssh foo+bar -# -# Each target separated by + has the following form: -# -# [user%]host[:port] -# -# Note the use of % instead of @ to get around the parsing that ssh -# itself does. -# -# Using the above configuration, when the user runs "ssh foo+bar", -# the following happens: -# -# * ssh matches "foo+bar" to the "Host *+*" section, and runs -# the proxy command. -# -# * The proxy command invokes "ssh foo -W bar:22", which means -# it connects to foo and forwards the local stdin/stdout to -# bar's ssh port. The forwarding happens over the secure link -# to foo. -# -# * The ssh started by the user uses the proxy command's -# stdin/stdout to talk to what it thinks is the "foo+bar" -# server. In other words, instead of making a TCP connection -# to the host named "foo+bar" and sets up an encrypted channel -# over that TCP connection, it uses the stdin/stdout of the -# proxy command instead. -# -# In other words, the ssh client started by the user talks to -# the ssh server on bar, but the communication goes via the -# secure channel to foo. -# -# Additionally, this script gives ssh options to set the remote user -# and port for the first host in a chain. - -import re -import sys - -import cliapp - - -def debug(msg): - # Set condition below to true to get debug output to stderr. - if False: - sys.stderr.write('SSHVIA DEBUG: {}\n'.format(msg)) - - -def panic(msg): - sys.stderr.write('SSHVIA ERROR: {}\n'.format(msg)) - sys.exit(1) - - -def extract_last_target(full_target): - # Input is foo+bar. Return foo, bar. - i = full_target.rfind('+') - if i == -1: - return None, full_target - return full_target[:i], full_target[i+1:] - - -def extract_targets(full_target): - targets = [] - remaining = full_target - while remaining: - remaining, target = extract_last_target(remaining) - targets.append(target) - return list(reversed(targets)) - - -def parse_target(target): - # Input is of the form: [user%]host[:port] - # Return user, host, port (None for user, port if missing). - - percent = target.find('%') - colon = target.find(':') - - user = None - port = None - - if percent == -1 and colon == -1: - # It's just the host. - host = target - elif percent >= 0 and colon >= 0 and percent < colon: - # It's user%host:port - user = target[:percent] - host = target[percent+1:colon] - port = target[colon+1:] - elif percent >= 0 and colon >= 0 and percent >= colon: - # it's an error - panic('Do not understand %r' % target) - elif percent >= 0: - # It's user%host - user = target[:percent] - host = target[percent+1:] - elif colon >= 0: - # It's host:port - host = target[:colon] - port = target[colon+1:] - else: - # it's a programming error - panic('Confused by %r' % target) - - return user, host, port - - -# ssh parses its own command line, and extracts target host, target -# port, and target (or remote) username. However, since ssh doesn't -# actually understand the + syntax itself, it gets things muddled: it -# parses user1@host1:8888+user2@host2:2222 in ways that will confuse -# users. Thus, we want the user to use % instead of @ so that ssh -# doesn't get in the way. -# -# ssh also allows the user to provide the remote user with the -l -# option, but we do not need to care about that, since it'll only be -# used to log into the last host in the chain. -# -# We do need to care about ports. ssh's -p option may be used for the -# last host in the chain, but every host in the chain may use : to -# separate a port number. - - -# Parse command line. We expect the full host (%h) and the port for -# thst last host in the chain (%p). That port may be the default 22, -# and will be overriden by the post in the full host if given. - -debug('argv: %r' % sys.argv) -full_target, last_target_default_port = sys.argv[1:] - -targets = extract_targets(full_target) -debug('targets: %r' % targets) -if len(targets) < 2: - panic('ERROR: Must be called with foo+bar syntax!') - -first_target = targets[0] -middle_targets = targets[1:-1] -last_target = targets[-1] - - -# Extract user from first target. -first_user, first_host, first_port = parse_target(first_target) - -# Extract port from last target. Replace with default if missing. -last_user, last_host, last_port = parse_target(last_target) -if last_port is None: - last_port = last_target_default_port - -# Set up the argv array. -argv = ['ssh', '-W', '{}:{}'.format(last_host, last_port)] - -if first_user is not None: - argv.extend(['-l', first_user]) -if first_port is not None: - argv.extend(['-p', first_port]) -all_but_last = [first_host] + middle_targets -argv.append('+'.join(all_but_last)) - - -# Shell-quote everything in argv, to avoid shell metacharacters from -# causing trouble. -argv = [cliapp.shell_quote(x) for x in argv] - - -# Output the command. -debug('result: %r' % argv) -sys.stdout.write(' '.join(argv) + '\n') diff --git a/test-flacs b/test-flacs deleted file mode 100755 index 3028adc..0000000 --- a/test-flacs +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python - - -import multiprocessing -import os -import subprocess -import sys -import time - - -def test_flacs(job_queue, result_queue): - i = 0 - for filename in iter(job_queue.get, None): - p = subprocess.Popen(['flac', '--totally-silent', '--test', filename]) - p.communicate() - result_queue.put((filename, p.returncode == 0)) - i += 1 - if i >= 10: - time.sleep(1) - i = 0 - - -def find_files(root): - pathnames = set() - for dirname, subdirs, filenames in os.walk(root): - for pathname in [os.path.join(dirname, x) for x in filenames]: - if pathname.endswith('.flac'): - pathnames.add(pathname) - return pathnames - - -files = find_files(sys.argv[1]) - -job_queue = multiprocessing.Queue() -result_queue = multiprocessing.Queue() -for job in files: - job_queue.put(job) -for i in range(multiprocessing.cpu_count()): - p = multiprocessing.Process(target=test_flacs, - args=(job_queue, result_queue)) - p.start() -total = len(files) -bad = list() -for done in range(total): - result = result_queue.get() - sys.stderr.write('\r%d / %d done' % (done + 1, total)) - sys.stderr.flush() - if result: - filename, ok = result - if not ok: - bad.append(filename) - -for i in range(multiprocessing.cpu_count()): - job_queue.put(None) - -sys.stderr.write('\n') - -for filename in bad: - print 'BAD:', filename - diff --git a/test-flacs.1 b/test-flacs.1 deleted file mode 100644 index aabf8ce..0000000 --- a/test-flacs.1 +++ /dev/null @@ -1,25 +0,0 @@ -.\" Copyright (C) 2009 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH TEST-FLACS 1 -.SH NAME -test-flacs \- check FLAC files for correctness -.SH SYNOPSIS -.B test-flacs -.IR dirname ... -.SH DESCRIPTION -.B test-flacs -checks that FLAC files (*.flac) are OK, using "flac --test". -It reports the names of the files that are not OK. diff --git a/unpack-debian-sources b/unpack-debian-sources deleted file mode 100755 index 0b6f097..0000000 --- a/unpack-debian-sources +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -# -# unpack-debian-sources - unpack all Debian packages in a Debian -# repository -# -# Usage: unpack-debian-sources MIRROR SUITE [SECTION]... -# -# where MIRROR is the URL to a Debian mirror site, SUITE is the release, -# and SECTION is a section within the release. For example: -# -# unpack-debian-sources http://ftp.debian.org/debian etch main contrib -# -# If SECTION is missing, it defaults to "main contrib non-free" - -set -e - -die() -{ - echo "$@" 1>&2 - exit 1 -} - -fetch() -{ - wget -q -O - "$1" -} - -parse_sources() -{ - awk ' - /^Directory:/ { - if (dir && paths) print dir, paths - dir = $2 - paths = "" - } - /^Files:/ { infiles = 1; next } - infiles && /^ / { paths = paths " " $NF } - infiles && (NF == 0 || /^[^ ]/) { infiles = 0 } - ' -} - -showiferror() -{ - local temp="$(mktemp)" - if ! "$@" > "$temp" 2>&1 - then - cat "$temp" - rm -f "$temp" - exit 1 - fi - rm -f "$temp" -} - -unpack_dsc() -{ - ( - cd "$1" - dsc="$(ls *.dsc)" - showiferror dpkg-source -x *.dsc - ) -} - -[ "$2" = "" ] && die "Usage: $0 MIRROR SUITE [SECTION]..." - -mirror="$1" -suite="$2" -shift 2 -sections="$@" - -gpghome="$(mktemp -d)" -export GNUPGHOME="$gpghome" - -for section in $sections -do - sources="$mirror/dists/$suite/$section/source/Sources.bz2" - sources_tmp="$(mktemp)" - fetch "$sources" | bunzip2 > "$sources_tmp" - - num_packages=$(parse_sources < "$sources_tmp" | wc -l) - - n=0 - parse_sources < "$sources_tmp" | - while read dir paths - do - n=$(expr $n + 1) - if [ ! -d "$dir" ] - then - printf "$n/$num_packages: $dir\n" - temp="$(mktemp -d)" - for path in $paths - do - fetch "$mirror/$dir/$path" > "$temp/$path" - done - unpack_dsc "$temp" - for path in $paths - do - rm "$temp/$path" - done - mkdir -p "$dir" # Create parent dirs - rmdir "$dir" # Remove tail dir - mv "$temp"/* "$dir" # Move the _single_ dir, which has the src - fi - done -done diff --git a/unpack-debian-sources.1 b/unpack-debian-sources.1 deleted file mode 100644 index 87aa3bd..0000000 --- a/unpack-debian-sources.1 +++ /dev/null @@ -1,61 +0,0 @@ -.\" unpack-debian-sources.1 - manual page for unpack-debian-sources -.\" Copyright (C) 2008 Lars Wirzenius -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH UNPACK-DEBIAN-SOURCES 1 -.SH NAME -unpack-debian-sources \- unpack Debian source packages in a repository -.SH SYNOPSIS -.B unpack-debian-sources -.I mirror -.I release -.RI [ component ...] -.SH DESCRIPTION -.B unpack-debian-sources -finds all Debian source packages in an apt repository, downloads them, -and unpacks them. -.PP -The -.I mirror -argument is an http url to the mirror. -For example, -.IR http://www.debian.org/debian . -.PP -The -.I release -argument specifies the release to download, -such as -.IR etch , -or -.IR intrepid . -.PP -The optional -.I component -arguments specify the components within a release, -such as -.IR main , -or -.IR contrib . -If you don't specify any componentes, the default list of -.I "main contrib non-free" -is used. -.PP -The result of -.B unpack-debian-sources -is a directory tree mimicking the apt archive. -If a source package is in the apt archive at -.I pool/main/f/foo/foobar_1.2-3.dsc -the unpacked source package is at -.IR pool/main/f/foo . diff --git a/viewprof b/viewprof deleted file mode 100755 index e570676..0000000 --- a/viewprof +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2010-2014 Lars Wirzenius -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -import pstats -import sys - -if len(sys.argv) not in [2, 3]: - sys.stderr.write('Usage: obnam-viewprof foo.prof [sort-order]\n') - sys.exit(1) - -if len(sys.argv) == 3: - order = sys.argv[2] -else: - order = 'cumulative' - -p = pstats.Stats(sys.argv[1]) -#p.strip_dirs() -p.sort_stats(order) -p.print_stats() -p.print_callees() diff --git a/viewprof.1 b/viewprof.1 deleted file mode 100644 index a9089b6..0000000 --- a/viewprof.1 +++ /dev/null @@ -1,25 +0,0 @@ -.\" Copyright 2010 Lars Wirzenius <liw@liw.fi> -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.\" -.TH VIEWPROF 1 -.SH NAME -viewprof \- view Python profiler files -.SH SYNOPSIS -.B viewprof -.I foo.prof -.RI [ sort-order ] -.SH DESCRIPTION -.B viewprof -displays a Python profiler output file in human-readable form. diff --git a/whatismyip b/whatismyip deleted file mode 100755 index c9ee00c..0000000 --- a/whatismyip +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -set -eu -dig +short myip.opendns.com @resolver1.opendns.com @@ -1,35 +0,0 @@ -#!/usr/bin/python3 - - -import os - - -import cliapp -import yaml - - -class With(cliapp.Application): - - def add_settings(self): - self.settings.string( - ['env-file', 'e'], - 'read environment description from FILE', - metavar='FILE', - default=os.path.expanduser('~/.config/with-envs/environments.yaml')) - - def process_args(self, args): - env_name = args[0] - argv = args[1:] - - envs = self.get_environments() - print(envs) - env = dict(os.environ) - env.update(envs[env_name]) - cliapp.runcmd(argv, env=env, stdout=None, stderr=None) - - def get_environments(self): - filename = self.settings['env-file'] - return yaml.safe_load(open(filename)) - - -With().run() |