MikeTeo.net

A Software Technologist's Blog (Wanna Email Me?)

Getting tklbam to install on Ubuntu 14.04

January 26, 2015 By miketeo

I use tklbam from TurnKeyLinux to backup a number of Linux nodes on DigtalOcean and Amazon AWS.
However, tklbam support was broken on Ubtuntu 14.04 where you can’t install the tklbam software.

Below is my workaround to get tklbam to install on Ubuntu 14.04.

Read the rest of this entry »

I have noticed that there are quite a few requests for a network scanning application to search for Windows shared folders.
I thought this will be an interesting implementation for pysmb (a pure Python implementation of the SMB1 and SMB2 protocol that supports the Windows file sharing functionality) as well as for developers who are learning to use pysmb for their applications.

You will need Python 2.4 and above, and have installed pyasn1 and pysmb. Next, download the ScanNetworkForSMB.py script. Then, run the script with 1 IP address to scan for a single machine, or a start/end IP address pair to scan a range of IP addresses. If the scanned machine has its Windows sharing port (port 137) active, the script will print out its IP address together with the names associated with this machine.

Sample output

$bash> python ScanNetworkForSMB.py 192.168.1.2 192.168.1.256
Beginning scanning 255 IP addresses...

     192.168.1.2 --> CETUS WORKGROUP
   192.168.1.109 --> I7PC WORKGROUP

Query timeout. No replies from 253 IP addresses

smb:// URL Support in pysmb

May 4, 2012 By miketeo

Starting from pysmb version 1.0.4, application developers can utilize smb:// URLs with pysmb and urllib2 python package. One benefit from this is that if your existing application already supports downloads via other protocols like http or ftp, you can “upgrade” your application to support downloads from Windows shared folders or from Samba servers by making small modifications to your existing code.

pysmb tries to follow the smb URL scheme proposed in the IETF draft which is not much different from other standard URL schemes like http and ftp. In short, your smb URL should follow this format – smb://[<user>:<password>@]<host>[:<port>][/<share>/<path>/<filename>]

Read the rest of this entry »

pysmb 1.0.0 Released!

December 25, 2011 By miketeo

About 10 years ago, I have released the first version of pysmb. Since then, Microsoft Windows has made significant changes to the NTLM authentication protocol which causes pysmb to become incompatible with Windows Vista and Windows 7 machines.

Now, with the release of pysmb 1.0.0, you can write Python applications to transfer files on shared folders on Windows XP, Windows Vista and Windows 7, as well as on Unix machines running Samba. pysmb 1.0.0 remains faithful to its clause that it will remain a pure Python SMB/CIFS module without any need for binary compilation. For this to be possible, it has utilized other pure Python modules such as pyDES, MD4 and pyasn1.

In addition to its new compatibilities with the recent Windows OS, pysmb has also been rewritten to support other frameworks. At the moment, a Twisted NetBIOS and SMB/CIFS protocol implementation has been included with pysmb 1.0.0 sources. Please refer to the documentation in the sources for more details.

For more details on pysmb 1.0.0, please go to the pysmb project page to download it, or you can also run: “easy_install pysmb” to install it on your machine.

CLIPS专家系统实现经验

November 29, 2011 By miketeo

此贴原先以英文语言刊登在此处

本人在前些时候有机会推行一项结合CLIPS专家系统的网上订购和实时系统监控的项目。这两样功能无论是以过程语言或是面向对象语言来实现都有相当大的难度。主要是当逻辑因子和监控变量增加时,要评价这些变量的复杂性将会以指数增长的方式变得极其复杂。我们尝试以Python语言来实现这两样功能,可是初步实现这两样功能的源码出现六层次的嵌套IF-ELSE结构,而最终得被迫放弃。若我们坚持以Python来继续实现,想必将来的软件维护将会是一项艰巨的任务。

虽然CLIPS专家系统最终为我们解决了评价变量复杂性的问题,但是本人还是觉得CLIPS专家系统并不适用于所有的逻辑问题。

CLIPS编程范式需要激进的思想转变

必须放弃以过程方式来思考如何实现各个评价操作,各个操作须以个别规则来实现,而这些规则要以识别动作周期的方式在CLIPS环境里运行。当一组的规则匹配成功时,这将引发相关的动作指令。这些指令可能修正这些规则的一些先前条件,而匹配其他(甚至是原先)的规则。另一项值得注意的是要如何设计这些规则,让这些规则能按照您想要的顺序来引发,而要在同时避免添加太多的约束。各个规则的引发条件应该避免依赖其他规则的状态,也就是规则之间的耦合度应该降到最低点。

要有深层的领域知识

在编写CLIPS规则时,您要将您领域里的各个事物运行的知识整理成一系列的规则和模式。您可以尝试进行这一个过程,或是聘请专家来协助您。

执行应该是数据驱动或是模式驱动

当您需要以多个IF语句来推理多个变量时,这执行过程很可能是数据驱动或是模式驱动的。任何有一定规模的领域都会牵涉到十几个或更多的变量,这意味着您的过程或面向对象源码将会呈现网格结构或是包含多层次的嵌套IF-ELSE结构。CLIPS的语言规范能让您针对各组指令而设置个别的引发条件,但是要注意对CLIPS事实和类的规划,CLIPS事实和类的属性应该遵循数据封装的原理来设计。