Thursday, August 30, 2012

Teach me how to fish - python exception handling

I really do want to understand this documentation: from `pydoc try`

The ``try`` statement
*********************

The ``try`` statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" target]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite
So what exactly does the first line mean?
try_stmt  ::= try1_stmt | try2_stmt
. It's a bit confusing as I know how to implement very simple try statements like this;
try:
    import io
    print("importing io")
except ImportError:
    print("nothing to import")
    foo = None
try:
    import somefunctionthatdoesnotexist
    print("importing ...")
except ImportError:
    print("nothing to import")
    foo = None

Tuesday, August 21, 2012

fpm - flipping package manager

fpm -t rpm \
 --name dc_fe \
 --package dc_fe-`date +%d-%m-%y`.rpm \
 --license 'O2 Labs' \
 --architecture noarch \
 --description "automated build of digital confidence git repo" \
 --category 'Applications/Internet' \
 --maintainer 'John Maclean '\
 --url https://github.com/dogfood20/digital_confidence \
 --vendor 'John Maclean ' \
 --url 'https://github.com/dogfood20/digitalconfidence_fe.git' \
 -s dir /home/jmaclean/work/o2-network/digitalconfidence_fe 

core dump on box0 - IBM

this is on cato0
...skipping...
[   27.585133]  [] ? do_dbs_timer+0xf1/0x384 [cpufreq_ondemand]
[   27.585136] ------------[ cut here ]------------
[   27.585142] WARNING: at /root/kbuild2/28051/repo/kernel-2.6.32-220.17.1.el6/linux-2.6.32-042stab055.16/arch/x86/include
/asm/processor.h:1002 read_measured_perf_ctrs+0x78/0x84 [mperf]() (Not tainted)
[   27.585150] Hardware name: 9978A4G
[   27.585152] Modules linked in: cpufreq_ondemand acpi_cpufreq freq_table mperf vznetdev vzmon vzdev ipv6 nf_conntrack_tf
tp ipt_REJECT xt_state iptable_filter ipt_MASQUERADE iptable_nat nf_nat nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 ip_t
ables uinput tpm_tis tpm tpm_bios 8139too 8139cp mii sg microcode serio_raw i2c_i801 iTCO_wdt iTCO_vendor_support snd_hda_
codec_analog snd_hda_intel snd_hda_codec snd_hwdep snd_seq snd_seq_device snd_pcm snd_timer snd soundcore snd_page_alloc e
1000e ext4 mbcache jbd2 sr_mod cdrom sd_mod crc_t10dif ahci pata_acpi ata_generic i915 drm_kms_helper drm i2c_algo_bit i2c
_core video output dm_mirror dm_region_hash dm_log dm_mod [last unloaded: scsi_wait_scan]
[   27.585198] Pid: 1610, comm: kondemand/1 veid: 0 Not tainted 2.6.32-042stab055.16 #1
[   27.585203]  [] ? do_dbs_timer+0x0/0x384 [cpufreq_ondemand]
[   27.585208]  [] ? worker_thread+0x190/0x2d0
[   27.585211] Call Trace:
[   27.585215]  [] ? warn_slowpath_common+0x87/0xc0
[   27.585221]  [] ? autoremove_wake_function+0x0/0x40
[   27.585224]  [] ? worker_thread+0x0/0x2d0
[   27.585228]  [] ? warn_slowpath_null+0x1a/0x20
[   27.585233]  [] ? read_measured_perf_ctrs+0x78/0x84 [mperf]
[   27.585237]  [] ? kthread+0x96/0xa0
[   27.585242]  [] ? child_rip+0xa/0x20
[   27.585246]  [] ? perf_event_task_sched_out+0x33/0x80
[   27.585250]  [] ? kthread+0x0/0xa0
[   27.585254]  [] ? child_rip+0x0/0x20
[   27.585258]  [] ? read_measured_perf_ctrs+0x0/0x84 [mperf]
[/pre]

fix...

what an unholy mess!

what an unholy mess. In the Slough office.... sudo yum install ruby-ri.x86_64 Loaded plugins: fastestmirror, protectbase, refresh-packagekit, security Loading mirror speeds from cached hostfile epel/metalink | 14 kB 00:00 * base: mirror.widexs.nl * epel: ftp.upjs.sk * extras: ftp.nluug.nl * openvz-kernel-rhel5: mirror.steadfast.net * openvz-kernel-rhel6: mirror.steadfast.net * openvz-utils: mirror.steadfast.net * rpmforge: be.mirror.eurid.eu * updates: mirror.nl.leaseweb.net adobe-linux-x86_64 | 951 B 00:00 base | 3.7 kB 00:00 extras | 3.0 kB 00:00 google-chrome | 951 B 00:00 ... local-repo | 4.0 kB 00:00 openvz-kernel-rhel5 | 951 B 00:00 openvz-kernel-rhel6 | 951 B 00:00 openvz-utils | 1.2 kB 00:00 rpmforge | 1.9 kB 00:00 rpmforge/primary_db | 2.5 MB 00:02 updates | 3.5 kB 00:00 updates/primary_db | 1.8 MB 00:01 0 packages excluded due to repository protections Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package ruby-ri.x86_64 0:1.8.7.352-7.el6_2 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================== Package Arch Version Repository Size ========================================================================================================================== Installing: ruby-ri x86_64 1.8.7.352-7.el6_2 base 2.4 M Transaction Summary ========================================================================================================================== Install 1 Package(s) Total download size: 2.4 M Installed size: 4.9 M Is this ok [y/N]: y Downloading Packages: ruby-ri-1.8.7.352-7.el6_2.x86_64.rpm | 2.4 MB 00:05 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : ruby-ri-1.8.7.352-7.el6_2.x86_64 1/1 Verifying : ruby-ri-1.8.7.352-7.el6_2.x86_64 1/1 Installed: ruby-ri.x86_64 0:1.8.7.352-7.el6_2 Complete!

Thursday, August 16, 2012

Perl Stuff

Installed Pod::Webserver from CPAN

Wednesday, August 8, 2012

Google's Galaxy Nexus

lsusb -s 001:006 Bus 001 Device 006: ID 18d1:4e41 Google Inc. ;-)