From c3481c703fbb84666f0617631a3d5b5da597008b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 9 Oct 2016 15:09:37 +0300 Subject: Remove obsolete scripts --- scripts/auto-disp | 63 ----------------------------- scripts/pbuilder-create | 104 ------------------------------------------------ 2 files changed, 167 deletions(-) delete mode 100644 scripts/auto-disp delete mode 100755 scripts/pbuilder-create diff --git a/scripts/auto-disp b/scripts/auto-disp deleted file mode 100644 index 6e43a6f..0000000 --- a/scripts/auto-disp +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python - - -import re - -import cliapp - - -class AutoDisp(cliapp.Application): - - lid = 'LVDS1' - externals = ['VGA1', 'HDMI1', 'DVI1', 'DP1'] - - def process_args(self, args): - out = self.runcmd(['xrandr', '-q']) - outputs = self.parse_outputs(out) - - got_internal = self.got_output(self.lid, outputs) - got_externals = [x - for x in self.externals - if self.got_output(x, outputs)] - - argv = ['xrandr'] - if got_externals: - res, name = max((outputs[x], x) for x in got_externals) - argv += ['--output', name, '--mode', '%dx%d' % res] - if got_internal: - argv += ['--output', self.lid, '--off'] - elif got_internal: - argv += ['--output', self.lid, - '--mode', '%dx%d' % outputs[self.lid]] - else: - raise cliapp.AppException('Oops, don\'t know what to do') - - self.runcmd(argv) - - def got_output(self, name, outputs): - return name in outputs - - def parse_outputs(self, xrandr): - output = re.compile(r'^(?P[A-Z0-9]+) connected ') - mode = re.compile(r'^ (?P\d+)x(?P\d+) ') - - result = {} - current = None - - lines = xrandr.splitlines() - for line in lines: - words = line.split() - output_match = output.match(line) - mode_match = mode.match(line) - if output_match: - current = output_match.group('output') - elif mode_match: - assert current is not None - x = int(mode_match.group('x')) - y = int(mode_match.group('y')) - prev = result.get(current, (0,0)) - result[current] = max((x,y), prev) - - return result - -AutoDisp().run() diff --git a/scripts/pbuilder-create b/scripts/pbuilder-create deleted file mode 100755 index 1afa2c6..0000000 --- a/scripts/pbuilder-create +++ /dev/null @@ -1,104 +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 . - - -import cliapp -import logging -import os -import subprocess -import time - - -class PbuilderCreate(cliapp.Application): - - def add_settings(self): - self.settings.string(['mirror', 'm'], - 'use URL for mirror (%default)', - metavar='URL', - default='http://cdn.debian.net/debian') - self.settings.string_list(['release', 'r'], - 'build tgz for RELEASE (%default)', - metavar='RELEASE', - default=['unstable']) - arch = self.runcmd(['dpkg', '--print-architecture']).strip() - self.settings.string_list(['arch', 'a'], - 'build tgz for ARCH (%default)', - metavar='ARCH', default=[arch]) - self.settings.string_list(['othermirror', 'o'], - 'also build tgz with pbuilder ' - '--othermirror, set to empty to avoid ' - 'this (%default)') - self.settings.integer(['max-age'], - 'trigger tgz update if older than N days ' - '(%default)', - metavar='N', default=1) - self.settings.boolean(['no-act', 'dry-run'], 'just pretend') - self.settings.boolean(['verbose'], 'print commands before executing') - self.settings.string(['directory', 'd'], - 'where to put tgz files (%default)', - default='/var/cache/pbuilder') - - def process_args(self, args): - for release in self.settings['release']: - for arch in self.settings['arch']: - self.pbuilder(release, arch, 'pristine', None) - if self.settings['othermirror']: - self.pbuilder(release, arch, 'custom', - self.settings['othermirror']) - - argv = ['pbuilder', '--clean'] - if self.settings['verbose']: - print ' '.join(argv) - self.runcmd(argv) - - def pbuilder(self, release, arch, suffix, othermirror): - tgz = self.tgz(release, arch, suffix) - if os.path.exists(tgz): - if not self.need_to_update_tgz(tgz): - return - argv = ['pbuilder', - '--update', - '--basetgz', tgz, - '--logfile', tgz + '.log'] - else: - argv = ['pbuilder', - '--create', - '--mirror', self.settings['mirror'], - '--architecture', arch, - '--distribution', release, - '--basetgz', tgz, - '--logfile', tgz + '.log'] - for x in othermirror or []: - argv += ['--othermirror', x] - if self.settings['verbose']: - print ' '.join(argv) - if self.settings['no-act']: - return - self.runcmd(argv) - - def need_to_update_tgz(self, tgz): - mtime = os.path.getmtime(tgz) - now = time.time() - max_age_secs = self.settings['max-age'] * 24 * 60 * 40 - return mtime <= now - max_age_secs - - def tgz(self, release, arch, suffix): - basename = '%s-%s-%s.tgz' % (release, arch, suffix) - return os.path.join(self.settings['directory'], basename) - - -if __name__ == '__main__': - PbuilderCreate().run() -- cgit v1.2.1