Home

Terrified of Qik @ 2010-06-29 22:00:18.554564
Filed under: Personal  Tech 
For those who don't know what qik is, it's a mobile application for taking videos and uploading them to the net as well as a "live" stream service from your phone for people to watch. I put live in quotes as, since one would expect, there is a delay depending on bandwidth, processing and other factors (it seems to be between 10-20 seconds usually). It's quite an interesting idea and seems to work decently well. For many phones this is a downloadable app but for us Evo users it is preloaded an, without hackery, can not be removed. Of course, this is par for course when it comes to bundled apps, but it's still no excuse as to why the practice is still done.

Anyway, I've noticed quite a few odd videos showing up online through qik. Now, a lot of these videos show up in the recent videso section and then disappear off the site 15-60 minutes later. Some you really can't tell WTF is going on (like in this). While others seem like accidental recordings. Take this video for instance. A few seconds of a steering wheel while you drive? Kind of odd. Or this and this ... odd as one usually tries to record something when they record. This is a guy telling someone else how to use it as he reads the instructions on his phone. How about this one which is in someones bag or purse. Then, just for fun, take Monk's sarcastic didn't mean to record video.

While some of the videos are just odd I tend to think a number of them were accidental. Why would you record 15 seconds of your phone moving around in your bag? Why record nothing but a few random words and no image? Why else would the videos have default names such as "A qik snippet of my life"? Have I convinced you at least some portion of these were accidental recordings? Good. We can move to the next step ...

Where do people use their smart phones? At the airport? Yes. Walking down a hall? Of course. At a restaurant? Sure ... but let's think of where else many people use their phones ... the bathroom. Now before you start running off stating that no one does that or you don't do that just think about it. Not much else to do but read or get that phone out and be productive! If you go into (almost) any decently sized company and hang out in the stalls you will end up hearing the beeping, keyboard/feedback clicks and alerts from smart phones (assuming you don't get kicked out for being creepy).

One more thing before we bring this all together. Having a forward facing and a rear facing camera is common on this new generation of phones. Both cameras tend to be at least webcam quality if not much better. For instance, the rear facing camera on my EVO is amazing while the forward facing one is in the better than average similar to iPhone range.

So here it is, why I'm terrified of Qik: With Qik and the ease of accidental recordings it is quite possible that one could record themselves in the bathroom and have it uploaded to the net for everyone to watch without the user realizing it for 15-60 minutes (which is my very unscientific estimate for how long it takes someone to tell someone else they posted a recording they don't think was meant to be posted). This is very close to the dream many people have when younger: going to school naked. Sure, in this case you are not naked, but everyone gets to see you in a bit of a compromising position. To make it worse, there is an automatic "good job" post that happens on some videos as if to encourage you to make more ... if you accidentally posted yourself in the bathroom and were told good job .... yeah.

So I leave you with the closest video to what I've described. No, this person is not in the bathroom but it kind of seems like how the video would end up looking:



EDIT
I lied ... this one is closer (but done on purpose) and kind of creepy:


 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:    


iPhone4 vs HTC Evo or She Doesn't Care @ 2010-06-29 09:59:43.261656
Filed under: Philosophy  Comedy  Tech 
Warning: Strong Language


 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:      


I Am No Longer F**kn' Up @ 2010-06-26 18:09:49.637923
Filed under: Linux  Tech 
After waiting what seemed like forever I was able to finally get an HTC EVO. Unless you wear iBlinders (seen below) you have heard of the HTC Evo. It wasn't very long ago that I found out I was "f**ckn' up" but not having one (see this). I am proud to say that is no longer the case!


iBlinders(R)(TM)(Patent No 1234567)


So here is the deal. About a week and a half ago I finally put myself on the Evo waiting list at the local Sprint store. I was told there was about 50 people in front of me. I went online to look to see if I could order direct from Sprint but they stopped taking orders until they could fulfill the current back orders (or so the graphic seemed to indicate). The only place I could find selling Evo's were Amazon and brick-and-mortar Sprint stores. Just to be safe I put in an order on Amazon -- it would take about 2 weeks to fulfill and I figured if one came through I should be able to cancel the other one.

Fast forward to today. I decided (on a whim ... I think) to drop in to the Sprint store and find out where I was on the waiting list. The friendly fellow behind the podium stated there was no more waiting list. Hmmm ... I thought about that for about 5 seconds and then responded saying that I never received a call over the last week and a half. He then informed me that if I could just hang out for a bit they could hook me up with one as 5 showed up not much sooner before I dropped in.

I stood awkwardly at the back of the store hoping that this would not turn out to be a mistake. I then saw a manager like fellow walk out of the back with an Evo box and take it to the guy who was behind the podium (now at a register helping a lady). I watched as he started to ring her up for an Evo when he called the manager back over and pointed at me.

Podium Guy: That guy over there is waiting on one too. He said he was on the waiting list but didn't get a call.
Manager: He is wrong. Everyone was called.
Podium Guy: Well, he didn't get a call.
Manager: Then he wasn't on the list

I started to get a bit frustrated. I was on the list ... or at least I was told I was on the list when I stopped in during my lunch break a week and a half ago. I stood there thinking that maybe I would have to fall back on my Amazon order and wait another 5 days before I would get my hands on the device.

The manager came back out from the bowels of the store (or maybe the left arm, it's hard to tell) and called me over. He asked me if I was waiting for an Evo and I told him that I was and that I stopped by a week and a half ago and got on the list but didn't get a call. His response was a friendly "If you were on the list, you got a call already and if you don't pick up then we take you off the list." I thought about arguing that point. I have a phone. It keeps track of who called me. They are Sprint. They can see who called me. I didn't get a call. I decided instead of getting upset I would give him a nugget of information so he knows I'm not trying to MBA (like BSing but being an elitist too) him out of a phone. I told him that I had come in a week and a half ago and was told there was about 50 people ahead of me on the list and that it was first come first serve. I also told him that the guy who took my reservation wrote my information down on a yellow legal pad and I'm not sure if that was the official list or a temporary one. I'm assuming something I said in there clicked with him because he told me not to go anywhere and he would go pull one of the last two out of the back for me ... and within minutes I was in process of getting my plan moved over for the new phone.

I've only spent about 30 minutes with the phone so far, but I am impressed. While the UI is not as polished as the Palm Pre, it is a very fast phone with a ton of options and abilities. It's also got some impressive hardware!! So far the only semi-negative experience I've had would be in getting the phone ... but then again I can't complain, I didn't get iPhone'd (or -- waiting hours if not days in attempts to get the hardware you preordered a month ago to work and then hopefully just work after that).

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:    


Python RPM Specs Needing a Loving Home @ 2010-06-22 16:37:30.688423
Filed under: Linux  Code  Tech  Fedora  Python 
I found myself in need of some (currently) unpackaged python libraries and tools so I decided to do some quick packaging. If you are using these libraries (or want to) on a Fedora, RHEL or CentOS system and want to start packaging in Fedora then one of these could be an easy jumping in package. Note that they are not perfect so they still need a bit of love before getting them approved but it's (slightly) easier than starting from scratch!

django-picklefield.spec: provides an implementation of a pickled object field
python-amqplib.spec: Client library for AMQP
python-anyjson.spec: Wraps the best available JSON implementation available in a common interface
python-billiard.spec: Multiprocessing Pool Extensions
python-carrot.spec: AMQP Messaging Framework for Python
python-importlib.spec: Backport of importlib.import_module() from Python 2.7
python-celery.spec: task queue/job queue based on distributed message passing (requires all of the above)

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:          


Why I Am Buying An HTC Evo @ 2010-06-16 16:55:05.879065
Filed under: Comedy  Tech 
The most obvious answer is that it looks great. A friend of mine (monk) got his late last week and just being around the device makes me want it more. Even with the awesome factor and gadget peer pressure there was still a slim possibility that I could pass on it and wait .... but then I watched a review the solidified it for me. The review is actually good but one specific section was what told me I need to buy it: 9m11s to 9m21s.



So let me break this down ,,,
"If you are a dude ..." Yes! I am a dude!
"... walking around ..." Yes! I do walk!
"... with a bunch of phones and electronics and all that ..." Yes! I carry phones and electronics!
"... and you got Sprint ..." Correct! I do have Sprint!
"... and you don't got this ..." Right! I do not have an HTC Evo!
"... your f*ckn' up ..." NO! I don't want to do that!!!!

Evo here I come!!

(Seriously though, the review is pretty good. Check it out)


 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:    


Changelog Format @ 2010-06-14 22:06:54.198506
Filed under: Code  Tech  Frustration  Fedora 
This has been bugging me fore a while. Many projects and products have a changelog. It's great! We can see in a file what changes have been made from release 1 to release 2. Wouldn't it be great to watch an upstream changelog file and use something like Buildbot that would trigger a build on a new release. Then my brain started working. It told me that humans are much better at parsing information provided in different textual formats or markups. Let me explain ....

Let's take a look at the victims project. Even though victims doesn't have a special changelog, we will follow the general scm changelog information. Victims has a changelog like so:

2010-05-20  Steve 'Ashcrow' Milner  

        * setup.py:
        added archivers module to the setup script
        [4cd8f0133b44] [tip]

2010-05-18  Steve 'Ashcrow' Milner  

        * README, src/victims/__init__.py, src/victims/archivers/__init__.py:
        rpm is now listed as a useable archive closing #8
        [e71ad437f9f4]


Based off this information we can easily create a parser! We care about the date, author/email, description and the release (tag). Through the magic of a little bit of regex the following works decent enough ...

(\d{4}-\d{2}-\d{2})  (.*)  <(.*)>\n\n.*:\n[ ]*(.*)\n[ ]*(.*)


Now we can parse changelogs! Yay! Oh, but then our brain explodes in fear since this is not the only project out there. Surely everyone uses the same format! Let's use nmap as a second project example.

# Nmap Changelog ($Id: CHANGELOG 18109 2010-06-14 18:48:07Z drazen $); -*-text-*-

o [NSE] Added additional vulnerability checks to smb-check-vulns.nse. These checks
  are intrusive and have MS06-025, MS07-029 designations.
  
o [NSE] Added dns-cache-snoop.nse by Eugene Alexeev. This script does
  cache snooping by either sending non-recursive queries or by measuring
  response times.


Well that isn't so bad! With a little regex we could ... wait ... if I have to do this twice with two different projects am I going to need to do this many, many more times before I create Skynet^H^H^H^H^H^Han uber parser smart enough to figure out what accent, dialect, markup, etc.. a changelog may be in? It sure seems that way!

This is when another thought entered by brain (TWO IN ONE DAY!!!): Surely someone else has thought of this. There must be a commonly used format that shares this information for easy inclusion. As it turns out, I could only find one format for this and it doesn't exactly match. The project I'm talking about is doap. While the project does seem interesting, it seems to focus more so on information about a project and it's services and not so much about project releases and changes that have happened between those releases.

Long story long .... am I out of luck? Is there not a format in the works to deal with release information such as this in an open way? If there really isn't, is anyone interested in creating a format? It seems to me that this would be quite useful for package maintainers, system administrators and developers. Hit me up on identi.ca or twitter if you know or a format or want to chat about what one would look like.

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:        


Apple Fan's Everywhere React To The New iPhone @ 2010-06-11 10:25:15.683228
Filed under: Comedy  Tech 

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:    


Updated Mercurial Config @ 2010-06-03 20:02:01.496252
Filed under: Code  Tech 
I've really taken a liking to using Mercurial for version control. I figured it was about time to post my updated personal config (~/.hgrc)!

[ui]
username = Steve 'Ashcrow' Milner 
editor = vim

[extensions]
hgext.convert =
hgext.graphlog =
hgext.gpg =
hgext.schemes =
hgext.patchbomb =
color =
mq =
bookmarks =
pager =
inotify =
rebase =

[pager]
pager = less -R

[diff]
git = True

[alias]
blame = annotate -uln

[smtp]
# removed ;-)

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:    


Hello Guruplug You Jerk @ 2010-05-17 23:16:53.858363
Filed under: Linux  Tech  Frustration 
So you bought a Guruplug. You've waited and waited and now it's at your front door taunting you. You rip open the packaging and find a place in your networking closet to plug it in. Ethernet cord plugged in you plug the Guruplug in and watch your router logs. Nothing. Restart the plug and watch logs. Nothing. Change ethernet ports, reboot and watch logs. Nothing. Nothing. Nothing. ARRGGGG!

Don't fear -- here is some help. Before I start please note most of this information came from the forums at plugcomputer.org. Also note I am tired and cranky.

First, unplug the Guruplug and unplug the ethernet cord from the device. Before an ethernet connection will work you will need to ensure that your router/switch is 10/100 and not a gigabit router/switch. This may seem odd but many people have found plugging into gigabit devices (even those which can sense and fail downwards) causes the Guruplug to plainly not work. Go find an old router/switch and patch it in to your modern gigabit switch and then plug the guru plug in through there. While it shouldn't matter (at least I don't *think* it should matter) which ethernet jack you use note I have only tested it with the top one (the one closest to the logo and lights).

Lookie there! You see the Guruplug in your router logs now with an IP address. Great! ssh on over with the root user and the default password of nosoup4u (yeah -- really, that is it). Before you do anything else, STOP! Do you need the wifi device running? Anyone is able to join the network and use your connection! Even if you are going to be using the wifi in the Guruplug in your project you probably do not need it running at this point, so let's turn it off temporarily by running "uaputl sys_cfg_radio_ctl off". Use your desktop/laptop and check to make sure that you can no longer see the GuruPlug SSID (it may take a minute or two you to see). If you know you are not going to be using the Wifi for a while you can turn it off by editing /root/init_setup.sh and comment out everything from "rm -f /etc/wlanclient.mode" up to and including "/usr/bin/uaputl bss_start". The file should now look like this:

# We always bootup in AP mode. Delete any stale files
#rm -f /etc/wlanclient.mode
#SSID=Plug2-uAP-`ifconfig eth0 | awk -F ":" '/HWaddr/ {print $6$7}'`
#
#insmod /root/uap8xxx.ko
#ifconfig uap0 192.168.1.1 up
#/usr/bin/uaputl sys_cfg_ssid $SSID
#/usr/bin/uaputl bss_start
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
/etc/init.d/udhcpd start
/etc/init.d/dnsmasq start
iptables -A INPUT -i uap0 -p tcp -m tcp --dport 80 -j ACCEPT

# Re-enable bluetooth. In the earlier case, it didn't find the firmware.
#rmmod libertas_sdio libertas btmrvl_sdio btmrvl bluetooth 2>/dev/null
rmmod btmrvl_sdio btmrvl
/etc/init.d/bluetooth start

modprobe btmrvl_sdio
hciconfig hci0 up
hciconfig hci0 piscan
/usr/bin/mute-agent &

# Set leds
echo 1 > `eval ls /sys/class/leds/*plug*\:green\:health/brightness`
echo 1 > `eval ls /sys/class/leds/*plug*\:green\:wmode/brightness`

Now let's get that root password changed! We don't want someone iPhoning us! All you need to do is run "passwd". You will be prompted for your new password two times. Now the root password is no longer nosoup4u, it is what you just set it to. Don't forget it.

As any good engineer you just tried to update the system (you are a good engineer aren't you?). The problem here is that, well, it didn't work.

Err http://10.82.108.51 binary/ Release.gpg    
  Could not connect to 10.82.108.51:80 (10.82.108.51). - connect (110 Connection timed out)
Err http://10.82.108.51 binary/ Translation-en_US
  Could not connect to 10.82.108.51:80 (10.82.108.51). - connect (110 Connection timed out)
Ign http://10.82.108.51 binary/ Release        
Ign http://10.82.108.51 binary/ Packages/DiffIndex
Ign http://10.82.108.51 binary/ Packages       
Err http://10.82.108.51 binary/ Packages       
  Could not connect to 10.82.108.51:80 (10.82.108.51). - connect (110 Connection timed out)
W: Failed to fetch http://10.82.108.51/kedars/sheevaplug_wifi/builds/packages/binary/Release.gpg  
Could not connect to 10.82.108.51:80 (10.82.108.51). - connect (110 Connection timed out)

W: Failed to fetch http://10.82.108.51/kedars/sheevaplug_wifi/builds/packages/binary/en_US.gz 
 Could not connect to 10.82.108.51:80 (10.82.108.51). - connect (110 Connection timed out)

W: Failed to fetch http://10.82.108.51/kedars/sheevaplug_wifi/builds/packages/binary/Packages  
Could not connect to 10.82.108.51:80 (10.82.108.51). - connect (110 Connection timed out)

E: Some index files failed to download, they have been ignored, or old ones used instead.
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. 

As the error states, go ahead and run "dpkg --configure -a". Then edit /etc/apt/sources.list and comment out the silly internal to the manufacturers network IP address so the file looks like this:

deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
deb http://http.us.debian.org/debian stable main contrib non-free
deb http://security.debian.org lenny/updates main contrib non-free
deb http://www.backports.org/debian lenny-backports main contrib non-free
#deb http://10.82.108.51/kedars/sheevaplug_wifi/builds/packages/ binary/

Now run "apt-get update && apt-get upgrade" to get that system updated. This will take a bit of time. While that runs go learn about Mentally Ill Gangsters


OK, now we see all those stupid messages saying we are getting stuff from the future. That is cool and all but we don't need to hear about time traveling code over and over. Let's fix it using date. You will need to run date like so 'date -s "+Mon May 17 22:50:00 EST 2010"'. Now you will need to really set the timezone (assuming you are not in UTC). To do this replacing EST with your correct timzeone: "cd /etc/; mv localtime localtime.old; ln -s /usr/share/zoneinfo/EST localtime".

Now is the moment of truth. Reboot the plug by running "reboot". It will probably come back up with the same IP address (punch a tree in the face), but if you can't get to the plug check your routers logs to see if it got assigned another address. Everything should be great and you should be off to the races. YES DICE! Now I need sleep. I have no more caffeine powering my madness.

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:      


victims demo @ 2010-05-09 00:39:40
Filed under: Code  Tech  Security 

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:      


python-dulwich spec file @ 2010-04-16 20:39:42
Filed under: Linux  Tech  Fedora  Python 
I was looking at Anyvc when I couldn't seem to find a dulwich package in Fedora. I threw together a spec file so I could test out anyvc (it's pretty cool by the way). I don't intend to maintain a dulwich package since I use Mecurial most of the time these days. Nothing against Git, I still like it!

If you are interested and taking the spec and running with it as a maintainer you can find it here.

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:        


Bad Java, BAD! No More Jars! @ 2010-03-27 23:26:42
Filed under: Code  Tech  Security  Frustration  Python 
A big frustration for me is the sprawl of Jar's (java "packages") which are everywhere. These special zip files tend to be copied into other applications and then left alone. Many of these Jar's have newer releases to fix security issues, but the bundled version isn't updated. It's even worse that many Jar's don't provide enough meta information that you can be sure of who owns it. Yes, you could keep SHA1SUM's in a database like maven does, and that is better than nothing, but it's not really a fix, it's a hack.

Here is an example of metadata that came with one Jar:

Manifest-Version: 1.0
Created-By: 1.6.0_10 (Sun Microsystems Inc.)

How helpful! Well, we can at least see what it is by the name of the file: sqlitejdbc.jar. It still doesn't tell us what version. Let's look at another:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: fberger
Build-Jdk: 1.6.0_06

Better, but still isn't that helpful. In this case we get lucky as some of the info is in the file name: gettext-commons-0.9.6.jar.

It really seems like the whole 'keep metadata in your Jar' is more of an inside joke which requires a hack to try to track what jars to include (as maven does). Welcome to Jar hell. How fun. Anyway, here is another hack ...

For the heck of it I decided to write a very simple scanner. It reads the metadata from the Jar file and then tries to match it up against an online database. If it gets no results back it keeps it as 'either safe or not enough information'. If there isn't even enough data to make a call out to the database it's assumed bad and tells you the user to bother about it if that is listed, and if the database confirms vulnerabilities it's known bad. It needs a lot of work to better guess information not provided by the metadata but here is an example run (with some changes to protect the guilty)

$ python jarscanner.py *jar
WARNING:root:apache-mime4j-0.6.jar is the latest secure version or not enough info
WARNING:root:commons-codec-1.3.jar is the latest secure version or not enough info
WARNING:root:commons-logging-1.1.1.jar is the latest secure version or not enough info
WARNING:root:hsqldb.jar is the latest secure version or not enough info
WARNING:root:httpclient-4.0.jar is the latest secure version or not enough info
WARNING:root:httpcore-4.0.1.jar is the latest secure version or not enough info
WARNING:root:httpmime-4.0.jar is the latest secure version or not enough info
INFO:root:jetty-6.1.7.jar found 15 vulns
INFO:root:jetty-util-6.1.7.jar found 15 vulns
WARNING:root:servlet-api-2.5-6.1.7.jar is the latest secure version or not enough info
WARNING:root:The following jars are known to be bad ...
WARNING:root:jetty-6.1.7.jar
WARNING:root:jetty-util-6.1.7.jar
CRITICAL:root:Sorry, but a number of jars are crap and don't provide enough information.
    These should be assumed bad!!!
CRITICAL:root:bdiff.jar
CRITICAL:root:fast-md5.jar (go bug dragonlz about it)
CRITICAL:root:gettext-commons-0.9.6.jar (go bug fberger about it)
CRITICAL:root:jcip-annotations.jar
CRITICAL:root:linuxfolderwatcher.jar
CRITICAL:root:messages.jar
CRITICAL:root:snakeyaml-1.5.jar (go bug somov about it)
CRITICAL:root:sqlitejdbc.jar
CRITICAL:root:stringtree-json-2.0.9.jar
CRITICAL:root:swt.jar
CRITICAL:root:unixapi.jar
CRITICAL:root:XXXXXXXXXX.jar
CRITICAL:root:XXXXXXXXXX.jar


I'm tired. I'm going to bed. I'll throw the code up somewhere tomorrow.

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:          


Patch For python-nmap @ 2010-03-24 16:01:12
Filed under: Code  Tech  Security  Python 
I discovered python-nmap but noted that it blocks. I threw together a quick wrapper for scanning for using in my own stuff and figured I might as well post it :-). Let's see if it goes upstream!
#!/usr/bin/env python
# By Steve 'Ashcrow' Milner

import nmap

try:
    from multiprocessing import Process, Queue
except ImportError:
    # For pre 2.6 releases
    from threading import Thread as Process
    from Queue import Queue


class NmapProcess(object):
    """
    Process scans in a non-blocking way.
    """

    def __init__(self, host):
        """
        Creates an instance.

        :Parameters:
           - `host`: host to scan
        """
        self.__host = host
        self.__queue = Queue()
        self.__nm = nmap.PortScanner()
        self.__process = None

    def scan(self, ports=None, arguments='-sV', callback=None):
        """
        Starts the scan taking the same input as nmap scan except the host.

        :Parameters:
           - `ports`: ports to scan
           - `arguments` arguments for nmap
           - `callback`: optional callback to execute when results are available
        """

        def scan_process(ports, arguments, callback=None):
            self.__nm.scan(self.__host, ports, arguments)
            self.__queue.put(self.__nm)
            if callback and callable(callback):
                callback(self.__nm)

        self.__process = Process(
            target=scan_process, args=(ports, arguments, callback))
        self.__process.daemon = True
        self.__process.start()

    def __get_results(self):
        """
        Returns results if they are available, else None.
        """
        if self.__queue.empty():
            return None
        return self.__queue.get()[self.__host]

    def __del__(self):
        """
        Clean up.
        """
        self.__process.join()

    # Properties
    results = property(__get_results)
    results_available = property(lambda s: not s.__process.is_alive())


if __name__ == '__main__':
    n = NmapProcess('127.0.0.1')

    def p(s):
        print("From Callback: " + str(s['127.0.0.1']))
    n.scan(arguments="-sV -T4 -A", callback=p)
    # Do stuff here ...
    from time import sleep
    while not n.results_available:
        print("Waiting ...")
        sleep(3)
    print("From property: " + str(n.results))

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:        


I've Lost My Mind @ 2010-03-13 23:27:00
Filed under: Code  Tech  Python 
Heh. I like MongoDB but I don't know why I wrote this ....

class _MongoSaveable(object):
    """
    Simple mongodb saveable object. Saves all attributes.

    You can force saves using a shortcut like so:
       >>> save = lambda s: s.__mongo_save__(COLLECTION)
       >>> save(my_instance)
    """

    _id = None
    _dirty = False

    def __setattr__(self, name, value):
        """
        TRY TO CATCH ME RIDN DIRTY *money money money*

        :Parameters:
           - `name`: key name
           - `value`: data to store
        """
        self.__dict__['_dirty'] = True
        self.__dict__[name] = value

    def __mongo_save__(self, collection):
       """
       Insert or Update data.

       :Parameters:
          - `collection`: the collection to associate with
       """
       if not self._dirty:
           return None
       result = {}
       for x in dir(self):
           if (not x.startswith('_') and
               not callable(getattr(self, x)) and
               x not in ("id", "dirty")):
               result[x] = getattr(self, x)
       if self._id:
           collection.save(result)
       else:
           saved_data = collection.find_one(result)
           if saved_data:
               self._id = saved_data["_id"]
           else:
               self._id = collection.insert(result)
       self._dirty = False

    dirty = property(lambda s: s._dirty)
    id = property(lambda s: s._id)


# PSUEDO EXAMPLE!!!!

import pymongo

from myapp import Example

# Connection stuff
DB = pymongo.Connection().my_database
COLLECTION = DB.my_collection

# Save shortcut
save = lambda s: s.__mongo_save__(COLLECTION)


class DataExample(Example, _MongoSaveable):
    def __init__(self, weight):
        self.weight = weight

    def calculate_status(self):
        if self.weight > 175:
            self.status = "lose wight"
        else:
            self.status = "doin fine"

ex = DataExample(150)
ex.calculate_status()
save(ex)
print ex.id # 4b9c6398bdcf5f4053000000
ex.goal_weight = 160
save(ex) 
print ex.id # 4b9c6398bdcf5f4053000000

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:      


Mongoose Web Server Spec @ 2010-03-10 20:19:33
Filed under: Linux  Code  Tech  Fedora  Python 
I happened to take a look at this and see there wasn't a package for it. It's one of those items that I don't have time to keep up with but I think would be a nice package to have in Fedora. If anyone wants to pick up with this and run with it be my guest!

The package includes a subpackage for devel (a single header file) and a subpackage for the Python bindings. There is also a patch to get the Python code to find the shared object.

Have fun!

Patch: mongoose-site-location.patch
--- bindings/python/mongoose.py	2010-03-10 20:07:53.735407453 -0500
+++ bindings/python/mongoose.py	2010-03-10 20:09:08.935760549 -0500
@@ -110,7 +110,8 @@
 
 	def __init__(self, **kwargs):
 		dll_extension = os.name == 'nt' and 'dll' or 'so'
-		self.dll = ctypes.CDLL('_mongoose.%s' % dll_extension)
+		from distutils.sysconfig import get_python_lib
+		self.dll = ctypes.CDLL(get_python_lib(1) + '/_mongoose.%s' % dll_extension)
 		start = self.dll.mg_start
 		self.ctx = ctypes.c_voidp(self.dll.mg_start()).value
 		self.version = ctypes.c_char_p(self.dll.mg_version()).value
Spec:
# sitearch for others (remove the unneeded one)
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}


Name:           mongoose
Version:        2.8
Release:        1%{?dist}
Summary:        Simple and easy to use web server

Group:          System Environment/Daemons
License:        MIT
URL:            http://code.google.com/p/mongoose/
Source0:        http://mongoose.googlecode.com/files/%{name}-%{version}.tgz
Patch0:         mongoose-site-location.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)


%description
Mongoose is an easy to use web server. It can be embedded into
existing application to provide a web interface to it.


%package python
Summary:       Python bindings for the mongoose web server
Requires:      mongoose


%description python
Mongoose is an easy to use web server. It can be embedded into
existing application to provide a web interface to it. This
package includes the bindings for the Python programming language.


%package devel
Summary:       Development files for the mongoose web server
BuildArch:     noarch


%description devel
Mongoose is an easy to use web server. It can be embedded into
existing application to provide a web interface to it. This
package includes the development files.


%prep
%setup -qn %{name}
%patch0


%build
make %{?_smp_mflags} linux


%install
rm -rf $RPM_BUILD_ROOT
# Install the base
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1/
cp %{name} $RPM_BUILD_ROOT/%{_bindir}
cp %{name}.1 $RPM_BUILD_ROOT/%{_mandir}/man1/

# Install the python bindings
mkdir -p $RPM_BUILD_ROOT/%{python_sitearch}
cp bindings/python/mongoose.py _%{name}.so $RPM_BUILD_ROOT/%{python_sitearch}

# Install the development files
mkdir -p $RPM_BUILD_ROOT/%{_includedir}/%{name}/
cp %{name}.h $RPM_BUILD_ROOT/%{_includedir}/%{name}/


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1.gz


%files python
%defattr(-,root,root,-)
%{python_sitearch}/_%{name}.so
%{python_sitearch}/%{name}.py*


%files devel
%defattr(-,root,root,-)
%{_includedir}/%{name}/


%changelog
* Wed Mar 10 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> 2.8-1
- Initial spec

 digg it   seed it   del.icio.us   ma.gnolia
Comments: 0 Tags:          


 
A Django joint.
© 2007-2009 Steve 'Ashcrow' Milner | Studio7designs | Arbutus Photography