Wednesday 9 April 2014

python 3.3, pyqt5 and cx_freeze exe on 64-bit windows

I am going to build a pyqt5 app on windows with python 3.3

the development platform:
1) Python 3.3.5x86-64 installer from https://www.python.org/downloads/release/python-335/
3) cx_freeze for Python 3.3 64 bit from http://cx-freeze.sourceforge.net/

install those applications, after that open windows command prompt by clicking start -> run (or Winkey+r shortcut)-> cmd -> enter, change directory to your python installion path, 'cd \python33' (change the path if you are not using default path and type without quotes)

then run '   python.exe -c "import sys; print (sys.version)"   ' in the prompt, you will get output like this,
3.3.5 (v3.3.5:62cf4e77f785, Mar  9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)]'

run ' path ', you will get,
PATH=C:\Python33\Lib\site-packages\PyQt5; ... more path here ...

also, check these paths exist, if they doesn't exist, there is something wrong of the installation
C:\Python33\Lib\site-packages\cx_Freeze
C:\Python33\Lib\site-packages\PyQt5

the hello world source code from https://gist.github.com/mizki9577/6856389
[helloqt.py]
#!/usr/bin/env python3
#-*- coding: utf-8 -*-

"""
helloqt.py
PyQt5 で Hello, world!
"""

import sys
from PyQt5 import QtWidgets

def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()
    button = QtWidgets.QPushButton("Hello, PyQt!")
    window.setCentralWidget(button)
    window.show()
    app.exec_()

if __name__ == '__main__':
    main()
copy and paste the code to your IDE, for example, PyCharm, at this moment you can use windows notepad and save the file to (for example): C:\Users\Administrator\Desktop\py33src\helloqt.py


to run it
in the command prompt, change directory to your python.exe path, 'cd \python33' (if you are not in that path), type ' python.exe c:\Users\Administrator\Desktop\py33src\helloqt.py ', you will get your hello world run

compile/pack/freeze python source code to exe for platform without python,
in command prompt, change directory to C:\Python33\Scripts by typing '  cd c:\python33\scripts  '
type and run:
cxfreeze.bat --base-name=Win32GUI c:\Users\Administrator\Desktop\py33src\helloqt.py
you will get helloqt.exe and its dependence files inside C:\Python33\Scripts\dist
note that --base-name=Win32GUI here is to hide the console window, you can try to compile without it to test the result

remind that libEGL.dll should be copied from C:\Python33\Lib\site-packages\PyQt5 to the same folder of the outputted .exe for the machine with no PyQt5 installed, otherwise the program will complain 'This application failed to start because it could not find or load the Qt platform plugin "windows"'

https://bitbucket.org/anthony_tuininga/cx_freeze/issue/51/pyqt5-python33-cx_freeze432
http://stackoverflow.com/questions/20495620/qt-5-1-1-application-failed-to-start-because-platform-plugin-windows-is-missi

PyQt5 Reference Guide:
http://pyqt.sourceforge.net/Docs/PyQt5/

PyQt5 Beginner tutorial:

Monday 30 December 2013

php exec no wait

I write a autohotkey exe to launch another exe
to simulate nohup on windows

[runnowait.ahk]
#NoTrayIcon
Loop, %0%
param := %A_Index%
Try
{
Run, %param%, , , OutputVarPID
FileAppend, %OutputVarPID%, *
}

Sunday 29 December 2013

bird's windows php shell, bird's winphpsh 20131226

2013.12.26 updated
 - code doesn't compatible with mongoose is //ed
 - remove empty line until file download code, downloaded file now won't mess up with leading 0D0A
 - css fix

since php shell 2.4 not really working on windows, the path problem,

google search,
"phpshell" cd: could not change to: /\/c:\
http://comments.gmane.org/gmane.comp.php.phpshell.devel/30
no help

so I write one for myself
http://birdsw.sourceforge.net/
http://sourceforge.net/projects/birdsw/files/winphpsh/
the php shell only work on windows, with download and upload function and it can be protected by login username and password

features:
one single php file, to run command, browse/change directory, upload/download files from any directory



exec, chdir

Sunday 27 October 2013

remove all files/driver installed for a printer

also fix printing status empty when print

start ->
devices and printers ->
print server properties ->
drivers ->
remove

Friday 7 September 2012

python 3 non-blocking read key input for windows using getch()


from msvcrt import kbhit,getch
#import time
stop = False
while not stop:
    print ("Hello world!")
    if kbhit():
        #print ('kbhit')
        #time.sleep(0.25)
        #print (getch())
        stop = getch()==bytes('q','ascii')

from msvcrt import kbhit,getch
import time
stop = False
while not stop:
    #print ("Hello world!")
    time.sleep(0.1)
    if kbhit():
        #print ('kbhit')
        #print (getch())
        #stop = getch()==bytes('q','ascii')
        stop = getch()==bytes('\r','ascii')



from msvcrt import kbhit,getch
import time, sys, threading, re
key = ""
terminate_this = 0
class MyThreadWithArgs(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
    def run(self):
        global key, terminate_this
        while True:
            time.sleep(0.01)
            if terminate_this == 1:
                break
            if kbhit():
                key = ord(getch())
                print(key)
                if terminate_this == 1:
                    break
##                    if key == 113:
##                        return
            pass
        return
try:
    t = MyThreadWithArgs()
    t.start()
    print (t)
    while threading.active_count() > 1:
        print ('do something here')
        time.sleep(0.5)
        if key == 113: # 'q' key to quit
            terminate_this = 1
            break
        if key == 97: # 'a' key
            print ('do something for a')
            key = ""
            pass
        pass
except KeyboardInterrupt: #ctrl+c
    terminate_this = 1
    sys.exit()
sys.exit()






Saturday 1 September 2012

Can't find out where CDLinux is installed - CDLinux


http://www.cdlinux.info/wiki/doku.php/doc/faq/bootiso not work

so,

title GNU/CDlinux
#extract bzImage and initrd to somewhere first
#no leading / or trailing / for CDL_DIR
#add  root (hd0,0) in first line to skip (hd0,0) in kernel and initrd lines
kernel (hd0,0)/path/to/bzImage quiet CDL_DIR=path/to CDL_IMG=CDlinux-0.9.7.1.iso CDL_LOOP=yes
initrd (hd0,0)/path/to/initrd
boot

 - or -

title GNU/CDlinux
#assume iso , kernel , initrd are on same partition
#no leading / or trailing / for CDL_DIR
find  --set-root  /path/to/CDlinux-0.9.7.1.iso
kernel /path/to/bzImage quiet CDL_DIR=path/to CDL_IMG=CDlinux-0.9.7.1.iso CDL_LOOP=yes
initrd /path/to/initrd
boot


Friday 31 August 2012

USB RMD-FDD and ubuntu booting issue

usb-creator-gtk creates FAT32 partition by default and mark the BOOT and LBA flag
but some motherboard only compatible with RMD-FDD will unable to boot

now use gparted to create FAT16 partition and mark only the BOOT flag, then it is ok

Thursday 16 August 2012

virtualbox android mount windows network share / drive

to build an android environment, I will use virtualbox
goto,
http://www.android-x86.org/download
get nightly build,
mariuz's site http://mariuz.android-dev.ro/
moonman's site http://android-x86.moonman.dk/
get the nightly build for x86 pc or vm (not really nightly :-< )

internet access,
setup nat of virtualbox if you use NAT http://www.virtualbox.org/manual/ch06.html#networkingmodes
 - or -
`route add ... ` in your command prompt for host-only adapter and use the IPEnableRouter registry, as well as a dhcp server in Files -> Preferences -> Network -> Dhcp Server
 - or -
some other else to route, software routing s/w like kerio wf, iptables and whatever

configure your virtualbox
I have a software router, and I use host-only adapter
(set up your own network type to have network access in your android virtual machine)


start your virtual machine,
start the installation,
Installation - Install Android-x86 to harddisk

Create / Modify partitions
New -> Primary -> [enter] -> [Bootable] + [enter] -> [Write] + [enter] -> yes + [enter] -> quit

sda1   Linux   VBOX HARDDISK
ext3
install GRUB
install /system as rw
Create a fake SD card
2047 [enter]

Remove the disk from virtual drive (by right clicking the cdrom icon)
Reboot


to send or receive (upload / download / transfer / access) files to a windows machine (a smb target),
first install AndSMB, from the website, grab the apk then execute it




hostname is the ip address or hostname of the SMB server, and need to be accessible form the virtual machine
 - on windows -
open command prompt by [winkey] + [r] -> cmd -> [enter]  or  start -> run -> cmd -> [enter]
enter the command `ipconfig` or `hostname` then you will get your ip and computer name
>ipconfig | find /i "ipv4"
   IPv4 Address. . . . . . . . . . . : 10.0.0.1
   IPv4 Address. . . . . . . . . . . : 192.168.0.2
   IPv4 Address. . . . . . . . . . . : 192.168.248.1
>hostname
WIN-U5XXXXXXXX9
 - on linux -
ifconfig

username and password,
 - on windows -
your account, admin account or any account has the privilege(permission of the sharing point) , password cannot be empty
`net share C$` to view your permission, `net user` to view all users on windows
`lusrmgr.msc` and `fsmgmt.msc` will help too, as well as `storagemgmt.msc` on server platform
`lusrmgr.msc` - Local Users and Groups
`fsmgmt.msc` - Shared Folders
`storagemgmt.msc` - Share and Storage Management
 - on linux -
specified in /etc/samba/smb.conf and passwd

Domain,
leave it blank, it is WORKGROUP as default in windows, not in a domain by default

Local dir,
where the files be placed when downloading it
don't confuse with mount point, not mount point

Remote dir,
 - windows -
there is "default share" in windows, which is C$ D$ E$ etc ... and the permission is always full (rw access)
use `net share` command to view or configure it, or right-click any drive icons in my computer or folders in else where, open its properties page, then you can configure sharing options in the sharing tab
 - linux -
specified in /etc/samba/smb.conf and can be various, https://help.ubuntu.com/12.04/serverguide/samba-fileserver.html



Server Message Block (SMB)
Common Internet File System (CIFS)






Monday 6 August 2012

zint to create version 1 to 40 qr code, identify to view their width and height


>seq -w 1 40 | sed -e "s/\(.*\)/--output=v\1a-z.png --scale 1 -b 58 --vers=\1 --secure=4 -d abcdefghijklmnopqrstuvwxyz/" | xargs --verbose --max-lines=1 zint

>identify -unique *.png
v01a-z.png PNG 66x66 66x66+0+0 8-bit DirectClass 531B 0.000u 0:00.001
v02a-z.png[1] PNG 66x66 66x66+0+0 8-bit DirectClass 531B 0.000u 0:00.000
v03a-z.png[2] PNG 66x66 66x66+0+0 8-bit DirectClass 531B 0.000u 0:00.000
v04a-z.png[3] PNG 66x66 66x66+0+0 8-bit DirectClass 531B 0.000u 0:00.000
v05a-z.png[4] PNG 74x74 74x74+0+0 8-bit DirectClass 646B 0.000u 0:00.000
v06a-z.png[5] PNG 82x82 82x82+0+0 8-bit DirectClass 752B 0.000u 0:00.000
v07a-z.png[6] PNG 90x90 90x90+0+0 8-bit DirectClass 921B 0.000u 0:00.000
v08a-z.png[7] PNG 98x98 98x98+0+0 8-bit DirectClass 1.08KB 0.000u 0:00.000
v09a-z.png[8] PNG 106x106 106x106+0+0 8-bit DirectClass 1.23KB 0.016u 0:00.000
v10a-z.png[9] PNG 114x114 114x114+0+0 8-bit DirectClass 1.38KB 0.000u 0:00.000
v11a-z.png[10] PNG 122x122 122x122+0+0 8-bit DirectClass 1.49KB 0.000u 0:00.001
v12a-z.png[11] PNG 130x130 130x130+0+0 8-bit DirectClass 1.69KB 0.000u 0:00.000
v13a-z.png[12] PNG 138x138 138x138+0+0 8-bit DirectClass 1.92KB 0.000u 0:00.000
v14a-z.png[13] PNG 146x146 146x146+0+0 8-bit DirectClass 2.12KB 0.000u 0:00.001
v15a-z.png[14] PNG 154x154 154x154+0+0 8-bit DirectClass 2.33KB 0.000u 0:00.000
v16a-z.png[15] PNG 162x162 162x162+0+0 8-bit DirectClass 2.52KB 0.000u 0:00.000
v17a-z.png[16] PNG 170x170 170x170+0+0 8-bit DirectClass 2.73KB 0.000u 0:00.000
v18a-z.png[17] PNG 178x178 178x178+0+0 8-bit DirectClass 3.02KB 0.000u 0:00.001
v19a-z.png[18] PNG 186x186 186x186+0+0 8-bit DirectClass 3.24KB 0.000u 0:00.001
v20a-z.png[19] PNG 194x194 194x194+0+0 8-bit DirectClass 3.5KB 0.000u 0:00.000
v21a-z.png[20] PNG 202x202 202x202+0+0 8-bit DirectClass 3.76KB 0.000u 0:00.000
v22a-z.png[21] PNG 210x210 210x210+0+0 8-bit DirectClass 3.67KB 0.000u 0:00.000
v23a-z.png[22] PNG 218x218 218x218+0+0 8-bit DirectClass 4.4KB 0.000u 0:00.000
v24a-z.png[23] PNG 226x226 226x226+0+0 8-bit DirectClass 4.58KB 0.000u 0:00.001
v25a-z.png[24] PNG 234x234 234x234+0+0 8-bit DirectClass 5.04KB 0.000u 0:00.000
v26a-z.png[25] PNG 242x242 242x242+0+0 8-bit DirectClass 5.25KB 0.000u 0:00.001
v27a-z.png[26] PNG 250x250 250x250+0+0 8-bit DirectClass 5.59KB 0.000u 0:00.000
v28a-z.png[27] PNG 258x258 258x258+0+0 8-bit DirectClass 5.89KB 0.000u 0:00.000
v29a-z.png[28] PNG 266x266 266x266+0+0 8-bit DirectClass 6.5KB 0.000u 0:00.000
v30a-z.png[29] PNG 274x274 274x274+0+0 8-bit DirectClass 6.8KB 0.000u 0:00.000
v31a-z.png[30] PNG 282x282 282x282+0+0 8-bit DirectClass 7.17KB 0.000u 0:00.000
v32a-z.png[31] PNG 290x290 290x290+0+0 8-bit DirectClass 7.45KB 0.000u 0:00.000
v33a-z.png[32] PNG 298x298 298x298+0+0 8-bit DirectClass 7.87KB 0.000u 0:00.001
v34a-z.png[33] PNG 306x306 306x306+0+0 8-bit DirectClass 7.45KB 0.000u 0:00.000
v35a-z.png[34] PNG 314x314 314x314+0+0 8-bit DirectClass 8.72KB 0.000u 0:00.000
v36a-z.png[35] PNG 322x322 322x322+0+0 8-bit DirectClass 8.3KB 0.000u 0:00.000
v37a-z.png[36] PNG 330x330 330x330+0+0 8-bit DirectClass 9.52KB 0.016u 0:00.000
v38a-z.png[37] PNG 338x338 338x338+0+0 8-bit DirectClass 10.1KB 0.000u 0:00.001
v39a-z.png[38] PNG 346x346 346x346+0+0 8-bit DirectClass 9.66KB 0.000u 0:00.000
v40a-z.png[39] PNG 354x354 354x354+0+0 8-bit DirectClass 10.4KB 0.000u 0:00.000

Thursday 2 August 2012

download tvb.com mytv video, download mytv, download tvb, 下載 tvb, 下載 mytv

http://www.nirsoft.net/utils/rtmp_dump_helper.html
http://github.com/downloads/svnpenn/rtmpdump/rtmpdump-v2.4-35-ge0056c5-master.7z
http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.4-git-010913-windows.zip

launch rtmpdumphelper and rtmpsuck manually
open url in a 32-bit browser (opera 32-bit, internet explorer 32-bit, firefox, chrome), 64-bit dll can't inject yet, (your flash is always 32-bit) 12-08-19 test of rtmpdumphelper v1.11 on mytv failed on my chome 21 ??!
fallback to the rtmpsuck - proxy server method, read the README file of rtmpdump, `Example Servers` section for more information.
And I created some shots may help
https://groups.google.com/d/topic/mytv_get_forum/NN5rWn61jxc/discussion
you need to read this as well
https://groups.google.com/forum/#!topic/mytv_get_forum/nFtKoiyMM7k/discussion

no binary for windows?!
nightly binary for windows
then compile rtmp on cygwin (simplest),
svn co svn://svn.mplayerhq.hu/rtmpdump/trunk rtmpdump 12-08-20
wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin/
apt-cyg install openssl-devel
git clone git://git.ffmpeg.org/rtmpdump
cd rtmpdump
make && make install
./rtmpsuck.exe

Labels

Search This Blog