說明文件–Buildbot在XP上安裝與Perforce 連線 (Install buildbot in xP connect with P4)

NET程式設計, 學習文件 No Comments »

Buildbot.jpg

要轉錄請務必標示文章出處:   BlogE www.evanlin.com/blog

甚麼是BuildBot?

Buildbot 是一套由Python撰寫的client-server 架構的專案source code追蹤用的伺服器。 主要可以拿來做以下的用途:

  • Code quality tracing: 可以定期或是只要有新的變動就主動下載source code並且build。 可以查出來哪個變動讓程式build不過。
  • Multiple platform compiler testing:  針對一份程式碼要對應到多個platform 或是多整module, Buildbot 提供了很好的方式可以幫助你確認這件事情。
  • Unit testing:  使用Buildbot 可以定期幫你的程式做unit testing。(當然~ unit testing program 得是你自己有準備好的)

需要的軟體:

在這裡先介紹所有你需要的軟體,可以事先去download 下來。

以上的版本已經確定在XP SP2 可以正確安裝並且執行無誤。希望各位也去下載適當版本。必須注意如果把Python換成新的版本(2.5 or 2.6)反而可能會造成安裝失敗。

或者你也可以去以下位置下載懶人包 。

懶人包: http://www.badongo.com/cn/file/12490044

 

安裝流程:

接下來你還必須要設定master.cfg 才能正常的啟動。

設定Buildbot:

  • Create MASTER
    1. "buildbot create-master <master_path>" <master_path> should be a path for Buildbot using.  For my case using "buildbot create-master MASTER".
    2. Modify master.cfg on the <master_path>. (you could refer as master.cfg as lastest of this article)
  • Create Slave
    1. buildbot create-slave bot1name bot1:8010 bot1 123(default Master port is the same with setting in Master.cfg)
      1. c[’slavePortnum’] = 8010 #default is 9989
  • Start Master
    1. "buildbot start MASTER"
  • Start SLAVE
    1. "buildbot start bot1"

    You could connect to http://localhost:10000 to see the server status.

    Master.cfg

    # 'master.cfg' in your buildmaster's base directory (although the filename
    # can be changed with the --basedir option to 'mktap buildbot master').
    
    p4env = {
    	'port': '192.168.XX.XX:XXXX',    #P4 connect port
    	'user': 'user',
    	'passwd': 'passwd',
    }
    
    # This is the dictionary that the buildmaster pays attention to. We also use
    # a shorter alias to save typing.
    c = BuildmasterConfig = {}
    
    ####### BUILDSLAVES
    
    # the 'slaves' list defines the set of allowable buildslaves. Each element is
    # a tuple of bot-name and bot-password. These correspond to values given to
    # the buildslave's mktap invocation.
    from buildbot.buildslave import BuildSlave
    c['slaves'] = [BuildSlave("bot1", "123")]
    
    # 'slavePortnum' defines the TCP port to listen on. This must match the value
    # configured into the buildslaves (with their --master option)
    
    c['slavePortnum'] = 8010
    
    ####### CHANGESOURCES
    
    # the 'change_source' setting tells the buildmaster how it should find out
    # about source code changes. Any class which implements IChangeSource can be
    # put here: there are several in buildbot/changes/*.py to choose from.
    
    from buildbot.changes.p4poller import P4Source
    c['change_source'] = P4Source(
    	                      p4base='//depot/Shared/Util/P4ReleaseNote/',
    	                      p4port = p4env['port'],
    	                      p4user = p4env['user'],
    	                      p4passwd = p4env['passwd'],
    	                      pollinterval= 60,
    	                      p4bin = 'c:/p4.exe',
    	                      split_file=lambda branchfile: branchfile.split('/',1),)
    
    #from buildbot.changes.pb import PBChangeSource
    #c['change_source'] = PBChangeSource()
    
    ####### SCHEDULERS
    ## configure the Schedulers
    
    #Periodic schedulerfrom buildbot.scheduler import Scheduler, Periodic
    periodic = Periodic("every_1_minutes", ["main"], 60)
    c[’schedulers’] = [periodic]
    
    ####### BUILDERS
    from buildbot.process import factory
    from buildbot.steps.source import P4 #Must include P4 library.
    from buildbot.steps.shell import Configure,Compile,Test
    from buildbot.steps.python_twisted import Trial
    
    #######		Builder for P4  #############
    f1 = factory.BuildFactory()
    f1.addStep(P4,
    	p4port = p4env[’port’],
    	p4user = p4env[’user’],
    	p4passwd = p4env[’passwd’],
    	p4client = ‘BuildBot’,
    	p4base = ‘//depot/Shared/Util/P4ReleaseNote/’,
    	mode = "copy")
    
    b1 = {
    	‘name’: "main",
    	’slavename’: "bot1",
    	‘builddir’: "main",
    	‘factory’: f1
    }
    
    c[’builders’] = [b1]
    
    ####### STATUS TARGETS
    c[’status’] = []
    
    from buildbot.status import html
    c[’status’].append(html.WebStatus(http_port=10000))
    
    from buildbot.status import mail
    c[’status’].append(mail.MailNotifier(fromaddr="evan.lin@evanlin.com",
                                         extraRecipients=["builds@example.com"],
                                         sendToInterestedUsers=False))
    ####### PROJECT IDENTITY
    c[’projectName’] = "Buildbot"
    c[’projectURL’] = "http://buildbot.sourceforge.net/"
    c[’buildbotURL’] = "http://localhost:10000/"

    後記:

    總算安裝跟設定好了吧~~~但是這樣僅僅只是讓你下載而已~~關於定期build的部分~ 我會研究出來後再分享給各位。 這裡有一些東西一定要注意到的是。 Perforce client spec must sync with your buildbot path。 如果沒有一樣的話,會發生下載下來檔案在原來client space 的地方,而不會在你預先設定的位置。

    Reference link (參考資料)

    1. Patrick: Buildbot + p4 + windows http://www.scribd.com/doc/4808056/buildbot-p4-windows
    2. Buildbot manual http://buildbot.net/repos/release/docs/buildbot.html
    3. buildbot安装配置笔记   http://blog.chinaunix.net/u2/68938/showart_1076484.html
    4. buildbot系统维护知识  http://blog.chinaunix.net/u2/68938/showart_1111019.html
    5. buildbot setup trac! (Buildbot for WIKI) http://timchen119.blogspot.com/2007/02/buildbot-setup-trac.html
    6. How to build Mozilla with Buildbot  http://zenit.senecac.on.ca/wiki/index.php/Building_Mozilla_with_Buildbot
    7. User:Bhearsum:Build/Buildserver ref image https://wiki.mozilla.org/User:Bhearsum:Build/Buildserver_ref_image
    8. Development: Buildbot http://wiki.wxwidgets.org/Development:_Buildbot (Wiki page with full doc for buildbot)
  • Translate your PERL code to execute file in Win32

    NET程式設計, VC++程式設計 No Comments »

    Perl2EXE is a very useful program when you try to translate your PERL code to a execute file without PERL environment.

    There should be noted if you happen the same problem.

    1. Active PERL need install:
      Although we try to use Perl2EXE  to translate PERL to execute file. We still need PERL runtime environment in the compiler machine. (Don’t need for running machine).
    2. Make sure Active PERL version is pair with your  Perl2EXE
      For example if you use Perl2Exe V7.02 for Win32 , you must use Perl 5.8.0, Perl 5.6.1, Perl 5.6.0 and Perl 5.005 which Active PERL version is ActivePerl Perl 5.8.0 Build 806. Or you may get error as follow:

     

    C:\p2x-8.60-Win32>perl2exe.exe sample.pl
    Perl2Exe V8.60 Copyright (c) 1997-2005 IndigoSTAR Software
    Registered to evan:kkdai:20080010, ENT version
    Converting ’sample.pl’ to sample.exe

    C:\p2x-8.60-Win32>

     

     

    Which I use Perl2EXE  V8.8 but I don’t have Active Perl  5.88

    After I switch to Perl2EXE V8.6 and using Active PERL 5.86. It work as follows:

     

    C:\p2x-8.60-Win32>perl2exe.exe sample.pl
    Perl2Exe V8.60 Copyright (c) 1997-2005 IndigoSTAR Software
    Registered to evan:kkdai:20080010, ENT version
    Converting ’sample.pl’ to sample.exe

    C:\p2x-8.60-Win32>

    How to change and find Autoplay setting?

    NET程式設計, Vista學習心得, VC++程式設計 No Comments »

    AppPicker.JPG
    (Application Picker dialog from XP)

    Application Picker is a dialog which will show-up when you insert DVD title or new medium in your computer. It show all playable application and let you to choose one from the list.

    One day, I just woundering where can I find the setting? How could I change the autoplay icon?  How could change the autoplay string?

    Here is the detail document from MSDN: Preparing Hardware and Software for Use with AutoPlay

    In follows steps, I will show you how to use “REGEDIT.EXE” to find out the setting and how it work.

    Read the rest of this entry »

    Use VC8 create ATL Service will failed in CoInitialize

    NET程式設計, VC++程式設計 No Comments »

    Use VC8 (Visual Studio 2005) to create project is more easy than VC6(VC98), but however we may not CoInitialize ATL service as well. It always happen failed since you use your API to CoInitialize this service. But it iswork if you use VC6 to create the ATL service. The root cause is the sercurity issue as follow:

    http://msdn2.microsoft.com/en-us/library/xe2dxx5c(VS.80).aspx

    class CATL_SERVERModule : public CAtlServiceModuleT< CATL_SERVERModule, IDS_SERVICENAME >
    {
    public :
        DECLARE_LIBID(LIBID_ATL_SERVERLib)
        DECLARE_REGISTRY_APPID_RESOURCEID(IDR_ATL_SERVER, “{C08654FF-A0F1-4CFD-8A09-93D4768BCF14}”)
        HRESULT InitializeSecurity() throw()
        {
            // TODO : Call CoInitializeSecurity and provide the appropriate security settings for
            // your service
            // Suggested - PKT Level Authentication,
            // Impersonation Level of RPC_C_IMP_LEVEL_IDENTIFY
            // and an appropiate Non NULL Security Descriptor.
            return S_OK;
        }
    };
    

    The problem is VC8 move the the security implement the base-class and you at-least implement one security check in this section of code. The easy way to implement it is copy code from VC6 as follow:

            // TODO : Call CoInitializeSecurity and provide the appropriate security settings for
            // your service
            // Suggested - PKT Level Authentication,
            // Impersonation Level of RPC_C_IMP_LEVEL_IDENTIFY
            // and an appropiate Non NULL Security Descriptor.
    
                // This provides a NULL DACL which will allow access to everyone.
            CSecurityDescriptor sd;
            sd.InitializeFromThreadToken();
            hr = CoInitializeSecurity(sd, -1, NULL, NULL,
                 RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
    
            return S_OK;
    


    Powered by Zoundry

    How to handle YouTube in your program

    NET程式設計 No Comments »

    Home

    Summarized:
    YouTube the world largest bideo braofcast company. People usually watch video under the web site or use the mashup to integrate into theirown blog. This article describes the way to deal with YouTube  via C++ coding. I will show you how to handle YouTube  API using Web Browser or using C++ to write a simple sample to demo how to get response from YouTube. Also I also tell you help to write a simple program to download YouTube video via HTTP connection client.

    YouTube APIs
    YouTube already provide lots of APIs which could help us to query video detail, get list by tag, list popular… All you have to do is open a url which like

    http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=XXXX_ID&tag=TakeThat

    As you see the URL it separate into three part:

    1. "method=youtube.videos.list_by_tag": it
      is API name, whole API list is here.
    2. "dev_id=XXXX_ID": Every API request need a developer ID which you can request here.
    3. "&tag=TakeThat": This API could help to figure out the list of specific tag. Oh my favorite band is "Take That" ^_^.

    After you send the Http request via your browser, you would get the result XML as follow:

    Y_XML

    Yes, a XML based response which you could full handle it in any kinds of program you like.

    Download YouTube:
    Pick up any video from YouTube which like: http://youtube.com/watch?v=abK9WNFbKus&eurl=%2Findex. How to download it via Http connection? First I want to introduce a web site which can help you to transform your YouTube URL to a download-able address. 男丁格爾’s 脫殼玩 - FLV Video Parser Web 版 is a one of this web site.

    Because any playback from YouTube need request a SK(I don’t know what is stand for). How to get the SK? You can paste a URL like http://youtube.com/watch?v=abK9WNFbKus&eurl=%2Findex, and you open the source code of this page (Use IE to right click and "View Source"). Search a strinbg as follow:

     function writeMoviePlayer(player_div, force)
     {
      var v = "7";
      if (force)
       v = "0";

      var fo = new SWFObject("/player2.swf?hl=en&BASE_YT_URL=http://youtube.com/&video_id=1vjLC_gcftE&l=121&t=OEgsToPDskIwzbAyRDMe7MOVOjVzt-Qf&soff=1&sk=CxfMnY-qWhLIp4nOKIFWOgU", "movie_player", "450", "370", v, "#FFFFFF");

       fo.addVariable("playnext", 0);
      fo.addVariable("hl", getQueryParamValue("hl"));
      fo.addParam("allowFullscreen", "true");
        fo.addVariable("sourceid", "yw");
        fo.addVariable("sdetail", "m%3Auser%2Crv%3AabK9WNFbKus");
      player_written = fo.write(player_div);
     }

    Use the "RED" string and connect with http://www.youtube.com/get_video? it should be http://www.youtube.com/get_video?video_id=1vjLC_gcftE&l=121&t=OEgsToPDskIwzbAyRDMe7MOVOjVzt-Qf&soff=1&sk=CxfMnY-qWhLIp4nOKIFWOgU it could download the video from YouTube directly. (The URL may invalid after a period time, please request it again.)

    Sample Program:
    Any handle of YouTube could via Http connection clien which IE/FireFox… CHttpClient is a very useful simple http client program which write by C++. 

    It has a clear GUI and useful connection API to get/post and request to Web Site via HTTP. I modify this application and change it to deal with YouTube.

    Please download in
    http://www.badongo.com/file/3563196

    Any comment is welcome.

    在C#上使用類似sprintf的字串轉換

    NET程式設計 No Comments »

    Solving Constraints

    English Summary: This article describe about how to use String.Format to implement the same with sprintf or printf in C++. For English, Please refer this article for more detail.

    中文: 最近遇到一些好玩的現象~~ 再次就把解決方式寫下來吧~~ (這篇就不用寫英文了,要看英文的部份請看這篇文章)。

    最近在C#上面,想要輸出固定2個位元小數點浮點數~ 為了這件事情~~ 覺得有點難搞~~ 由於傳下來的數字是Double 來儲存的,並且有可能是循環小數 (比如說: 10/3 = 3.333)。 如果~~ 你單純的使用Math.Round() 比如以下的範例:

    Double buf = 3.33333333333333333;
    buf = Math.Round(buf , 2);

    這個時候~ 你還是會發現 buf 還是那一連串的小數點~ 而沒有再小數點第二位去取四捨五入。原因在於小數點數字過多~ 而產生了 exception 的發生。 這個時候我又想了一個方法,參考以下的code:

    Double buf = 3.33333333333333333;
    buf = Math.Abs(buf*100);
    buf = bug/100;

    很奇怪的~~ 這樣也是無法轉換到兩個小數點~ 還會變成原來的數字~~ (難道是最佳化?) 難道我得使用CallingConvention Enumeration  的方式,把sprintf 當作外在function call嗎?

    Imports System
    Imports Microsoft.VisualBasic
    Imports System.Runtime.InteropServices

    Public Class LibWrap
    ‘ Visual Basic does not support varargs, so all arguments must be
    ‘ explicitly defined. CallingConvention.Cdecl must be used since the stack
    ‘ is cleaned up by the caller.
    ‘ int printf( const char *format [, argument]… )

    <DllImport("msvcrt.dll", CallingConvention := CallingConvention.Cdecl)> _
    Overloads Shared Function printf ( _
        format As String, i As Integer, d As Double) As Integer
    End Function

    <DllImport("msvcrt.dll", CallingConvention := CallingConvention.Cdecl)> _
    Overloads Shared Function printf ( _
        format As String, i As Integer, s As String) As Integer
    End Function
    End Class ‘LibWrap

    Public Class App
        Public Shared Sub Main()
            LibWrap.printf(ControlChars.CrLf + "Print params: %i %f", 99, _
                           99.99)
            LibWrap.printf(ControlChars.CrLf + "Print params: %i %s", 99, _
                           "abcd")
        End Sub ‘Main
    End Class ‘App

    還好之後在網路上有找到相關的程式String.Format() 去做類似~ sprintf 的轉換.

    Double buf = 3.33333333333333333;
    string outputStr = String.Format("{0:f}", buf);

    要更多範例~~ 可以去這邊查詢

    Write a simple Windows SideShow program

    NET程式設計 No Comments »

    筆記型電腦上的 Windows SideShow

    Windows SideShow is a new technology in Windows Vista that supports a secondary screen on your mobile PC. With this additional display you can view important information whether your laptop is on, off, or in sleep mode. Windows SideShow is available in Windows Vista Home Premium, Windows Vista Business, Windows Vista Enterprise, and Windows Vista Ultimate. For more detail, please refer http://www.microsoft.com/windows/products/windowsvista/features/details/sideshow.mspx

    For Engineer to development a simple SideShow program:

    1. Make sure you using Vista RTM
    2. Download SideShow emulator: http://www.microsoft.com/downloads/details.aspx?FamilyID=bba99eb2-aa6d-4133-b433-933a2c4d41dc&displaylang=en
    3. Install VS2005.
    4. Install Windows Vista SDK and .NET (http://www.microsoft.com/downloads/details.aspx?FamilyId=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en)
    5. Open solution: C:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\winui\sideshow\HelloWorld\HelloWorld.sln
    6. Build it
    7. Run registery "HelloWorld.reg"
    8. Run bin file in C:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\winui\sideshow\HelloWorld\Debug\WindowsSideShowHelloWorld.exe
    9. Start Emulator, you should show "Hello World" here.~~~

    Windows SideShow 頁面

    Write simple WMI program

    NET程式設計 No Comments »


    (Diagram: 淺談CIM與WMI-名詞介紹)

    WMI (Windows Management Instrumentation) provide a kind of easy way to let you query data from your system (Ex: OS version, share folder name … etc).

    It is easy to understand, using WMI to query information is the same with query data from database. You can just using "SELECT * from Win32_Process" to find out all exist process in your computer.

    There are some examples which describe how to create it using C# or C++ code.

    There are serveral extension reading..
    Here is sample code of C#

    using System.Management;

    //This is equivalent to "SELECT * FROM Win32_Service"
    SelectQuery sysSQL = new SelectQuery("Win32_bios");

    MnagementObjectSearcher sysRet =
      
    new ManagementObjectSearcher(sysSQL);

    // Display each entry for Win32_bios
    foreach (ManagementObject sysInfo in sysRet.Get())
    {
     
    this.textBox1.Text = "Bios version: " + sysInfo["version"].ToString();
    }

    How to debug COM DLL registeration

    NET程式設計 No Comments »

    DebugSetting1

    I know many people feel confuse if your COM DLL failed during registeration (using RegSvr32 to register it). I spent a little time, and find out how to debug it. It can help you to find out what is the root cause. OK! let get start.

    How can we do if register COM dll failed?

    Firstable, you can use "dumpbin /dependents YOURDLL.DLL" to find out if you lost some dependency DLL.

    Ok! ~~ let go to debug DLL registeration.

    1. Right click you DLL project –> Open "Properties".
    2. Go to "Configuration Properties" –> "Debugging" .
    3. In "Command", fill it "C:\WINDOWS\system32\regsvr32.exe"
    4. In "Command Arguments", fill it "$(TargetPath)"
    5. Just press F5 to run it.

    Please note, you should setting break point as follows:

    • DllMain
    • DllRegisterServer
    • DllUnregisterServer (if unregister failed).

    That’s it~~~

    利用VS2005來做ASP.NET 開發前的注意事項

    NET程式設計 No Comments »

    www.asp.net Home

    利用VS2005來作為ASP.NET的開發平台~~ 說老實的~~ 寫過不少Web Application的我還真是沒試過~~  (我是使用無敵記事本~~ 加上FTP 上傳的笨蛋)  心血來潮之下~ 在家裡測試了一下~~ 反而發現~~ 原來在安裝上面~還有許多需要注意的地方~~~

    1. ASP.NET 使用者的權限: .Net FrameWork 2.0 在安裝的時候~ 都會幫你設定一個使用者~~ 叫作ASP.NET~ 而他的作用就是代表者~~ 你localhost 要執行ASP.NET的程式時~~ 所允許的權限. 很多時候~~ 大家可能會把這個使用者給封鎖或是刪除, 如果這個使用者已經被刪除了~~~ 重新安裝一次.Net FrameWork 2.0  就可以了~~~ 安裝完後~可以選擇提高 ASP.NET使用者的權限 (我自己是調到最高~大家可以自己決定).
    2. Integrated Windows authentication is not enabled:  這個問題~~是我在安裝完並且修改完權限之後所發現的.  要解決這個問題~~ 我搜尋網路之後~~ 發現這篇文章 Unable to start debugging on the web server.Debugging failes because integrated Windows authentication is not enabled.  有講解到解決方式~~其實很簡單~~我摘錄該文章裡面的附圖.

      就注意好~~ 把滑鼠指到的那個項目點到就好~~~

    現在總算可以用平常上班的VS2005 來做網路程式的撰寫~~ 感覺就興奮異常阿~~~~

    WP Theme & Icons by N.Design Studio
    Entries RSS Comments RSS 登入