Artikel mit ‘script’ getagged

BeBeBeBeBörnd

Mittwoch, 23. Juni 2010

שָׁלוֹם

/usr/local/bin/berndget

#!/usr/bin/env python

import urllib2
import urllib
import BeautifulSoup
import sys
import re
import os

def stripfilename(url):
	base = urllib.unquote(os.path.basename(url))
	return base

def contains(theString, theQueryValue):
	return theString.find(theQueryValue) > -1

def _reporthook(numblocks, blocksize, filesize):
	sys.stdout.write(".")
	sys.stdout.flush()	

request = urllib2.Request(sys.argv[1])
response = urllib2.urlopen(request)
soup = BeautifulSoup.BeautifulSoup(response)
for a in soup.findAll('a'):
	link=a.get('href')
	if (link):
		if (contains(link, "/download/")):
			base=stripfilename(link)
			url="http://krautchan.net"+link
			print url+" --> "+base
			urllib.urlretrieve(url, base, _reporthook)
			print

By Bernd (sometimes under public domain)

Monday sucks

Montag, 01. Juni 2009

שָׁלוֹם

To mock F11 srpms for epel, you need to build the srpms with --define="_source_filedigest_algorithm md5". That sucks, too.

So long and thanks for all the fish :-)
שִׁמְעוֹן

my prompt and my issue

Freitag, 03. April 2009

שָׁלוֹם

cat /etc/issue

 _____        _
|  ___|__  __| | ___  _ __ __ _  Release: 10 (Cambridge)
| |_ / _ \\/ _` |/ _ \\| '__/ _` | Kernel: \r
|  _|  __/ (_| | (_) | | | (_| |
|_|  \\___|\\__,_|\\___/|_|  \\__,_| Terminal: \l

Result:
Nothing special
Fedora Login ASCII

excerpt of /etc/bashrc (above PS1 definition)

# Colors
normal=''
bold=''
black=''
darkgrey=''
red=''
lightred=''
green=''
lightgreen=''
brown=''
brown=''
blue=''
lightblue=''
violet=''
lightviolet=''
cyan=''
lightcyan=''
lightgrey=''
white=''

# define pwd
function show_pwd()
{
echo -e ${PWD////${normal}${bold}/${normal}${blue}}
}

excerpt of /etc/bashrc in the PS1 definition

    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1='${bold}.:[${normal} ${green}\u${normal} ${bold}@${normal} ${red}\h${normal} ${bold}:${normal} ${blue}$(show_pwd)${normal} ${bold}]:.${normal}\n\$ '

Result:(in an Gnome-Terminal)
The specialty of this (in comparison to other prompt-templates in the web) is that the seperator is colored in a different color than the direcory. :-) You can select another seperator if you want. :-)
Screenshot Gnome Terminal

So long and thanks for all the fish :-)
שִׁמְעוֹן

MockBuild

Donnerstag, 12. Februar 2009

שָׁלוֹם

Ein kleines Helferlein um den build mit mock etwas zu automatisieren…

/usr/local/bin/mockbuild

#!/bin/bash

BASEDIR=${HOME}/rpmbuild
FEDORAVER=${FEDORAVER:-"fedora-$(rpm --eval %{fedora})-$(rpm --eval %{_arch})"}
MOCKDIR=${BASEDIR}/mock-results/${FEDORAVER}
SPECDIR=${BASEDIR}/SPECS

if [ ${#} -lt 1 ]; then
  echo 'usage: mockbuild <packages>'
  exit 1
fi

# check directories
if ! [ -d ${BASEDIR} ]; then
  echo ${BASEDIR} not existent
  exit 1
fi
if ! [ -d ${SPECDIR} ]; then
  echo ${SPECDIR} not existent
  exit 1
fi

# check for special build (all specs)
if [ ${1} == '--all' ]; then
  list=$(ls ${SPECDIR}/*.spec | sed "s|${SPECDIR}/\(.*\).spec|\1|g")
else
  list=${@}
fi

for arg in ${list}; do
  # check directory for each pkg to build
  if ! [ -d ${MOCKDIR}/${arg} ]; then
    mkdir -p ${MOCKDIR}/${arg}
  else
    rm -f ${MOCKDIR}/${arg}/*
  fi

  # initiate the build
  rpmbuildout=$(LC_ALL=C rpmbuild -bs ${SPECDIR}/${arg}.spec) || exit 1
  $(LC_ALL=C mock -r ${FEDORAVER} --resultdir=${MOCKDIR}/${arg} ${rpmbuildout:7}) || exit 1
  $(LC_ALL=C rpmlint ${MOCKDIR}/${arg}/*.rpm > ${MOCKDIR}/${arg}/rpmlint) || exit 1
done

Mann ist mir langweilig :-) Und dann auch noch 42 Zeilen! Ich glaube ich brauch mein Handtuch :-)

So long and thanks for all the fish :-)
שִׁמְעוֹן

[XCHAT] simple substitution script

Dienstag, 09. September 2008

שָׁלוֹם

/home/cassmodiah/.xchat/sss.py

/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <bjoern.hiller@gmail.com> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Björn Benjamin Hiller
* ----------------------------------------------------------------------------
*/
# -*- encoding: utf-8 -*-
__module_name__ = 'sss'
__module_version__ = '1.0'
__module_description__ = 'simple substitution script'

import re, xchat

own_hook = False

def your_msg_cb(word, word_eol, userdata):
  global own_hook
  if own_hook:
    own_hook = False
    return xchat.EAT_NONE
  else:
    text = word_eol[0].replace('ä', 'ae').replace('Ä', 'Ae')
    text = text.replace('ö', 'oe').replace('Ö', 'Oe')
    text = text.replace('ü', 'ue').replace('Ü', 'Ue')
    text = text.replace('ß', 'sz')
    own_hook = True
    xchat.command('SAY %s' % text)
    return xchat.EAT_XCHAT

xchat.hook_command('', your_msg_cb)

So long
שִׁמְעוֹן

flv2avi

Sonntag, 01. Juni 2008

/usr/bin/flv2avi

#!/bin/sh

if [ -z "$1" ]; then
  echo "Usage: $0 {-divx|-xvid} list_of_flv_files"
  exit 1
fi

# video encoding bit rate
V_BITRATE=1000

while [ "$1" ]; do
  case "$1" in
    -divx)
      MENC_OPTS="-ovc lavc -lavcopts \
        vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoaspect"
      ;;
    -xvid)
      MENC_OPTS="-ovc xvid -xvidencopts bitrate=$V_BITRATE:autoaspect"
      ;;
    *)
      if file "$1" | grep -q "Macromedia Flash Video"; then
        mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame \
          -lameopts fast:preset=standard -o \
          "`basename $1 .flv`.avi"
      else
        echo "$1 is not Flash Video. Skipping"
      fi
      ;;
  esac
  shift
done

Mencoder muss installiert sein