Scarab commit: svn commit: r10335 - trunk/extensions/scripts

[email protected]
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: ptillemans
Date: 2006-11-07 18:07:16-0800
New Revision: 10335

Added:
   trunk/extensions/scripts/newTicket.py
   trunk/extensions/scripts/newticket.php

Log:
SCB2011: Create a new ticket using xmlrpc

Added some example scripts for creating a new ticket using PHP and Python

Added: trunk/extensions/scripts/newTicket.py
Url: http://scarab.tigris.org/source/browse/scarab/trunk/extensions/scripts/newTicket.py?view=auto&rev=10335
==============================================================================
--- (empty file)
+++ trunk/extensions/scripts/newTicket.py	2006-11-07 18:07:16-0800
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+ # ================================================================
+ # Copyright (c) 2000-2005 CollabNet.  All rights reserved.
+ # 
+ # Redistribution and use in source and binary forms, with or without
+ # modification, are permitted provided that the following conditions are
+ # met:
+ # 
+ # 1. Redistributions of source code must retain the above copyright
+ # notice, this list of conditions and the following disclaimer.
+ # 
+ # 2. Redistributions in binary form must reproduce the above copyright
+ # notice, this list of conditions and the following disclaimer in the
+ # documentation and/or other materials provided with the distribution.
+ # 
+ # 3. The end-user documentation included with the redistribution, if
+ # any, must include the following acknowlegement: "This product includes
+ # software developed by Collab.Net <http://www.Collab.Net/>."
+ # Alternately, this acknowlegement may appear in the software itself, if
+ # and wherever such third-party acknowlegements normally appear.
+ # 
+ # 4. The hosted project names must not be used to endorse or promote
+ # products derived from this software without prior written
+ # permission. For written permission, please contact [email protected].
+ # 
+ # 5. Products derived from this software may not use the "Tigris" or 
+ # "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
+ # prior written permission of Collab.Net.
+ # 
+ # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ # IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #
+ # ====================================================================
+ # 
+ # This software consists of voluntary contributions made by many
+ # individuals on behalf of Collab.Net.
+ #
+
+ 
+##############################################################################
+#  CONFIGURATION 
+##############################################################################
+#
+# basic configuration
+#          DISABLE_EMAILS:      1 == True, 0 == False
+
+SCARAB_XMLRPC_URL = "http://localhost:12345"
+
+
+from xmlrpclib import Server
+
+moduleName = "PAC"
+issueType = "Defect"
+userName = "[email protected]"
+
+attribs = dict()
+attribs['Status'] = 'New'
+attribs['Description'] = 'Some interesting stuff from python'
+attribs['AssignedTo'] = userName
+
+
+
+service = Server(SCARAB_XMLRPC_URL).newTicket
+id = service.createNewTicket(moduleName, issueType, userName, attribs)
+
+print id

Added: trunk/extensions/scripts/newticket.php
Url: http://scarab.tigris.org/source/browse/scarab/trunk/extensions/scripts/newticket.php?view=auto&rev=10335
==============================================================================
--- (empty file)
+++ trunk/extensions/scripts/newticket.php	2006-11-07 18:07:16-0800
@@ -0,0 +1,45 @@
+<?php
+
+function do_call($host, $port, $request) {
+  
+   $fp = fsockopen($host, $port, $errno, $errstr);
+   $query = "POST /home/servertest.php HTTP/1.0\nUser_Agent: My Egg Client\nHost: ".$host."\nContent-Type: text/xml\nContent-Length: ".strlen($request)."\n\n".$request."\n";
+
+   if (!fputs($fp, $query, strlen($query))) {
+       $errstr = "Write error";
+       return 0;
+   }
+
+   $contents = '';
+   while (!feof($fp)) {
+       $contents .= fgets($fp);
+   }
+
+   fclose($fp);
+
+   # strip header
+   $xml=(substr($contents, strpos($contents, "\r\n\r\n")+4));
+
+   # convert XML to PHP values
+   return xmlrpc_decode($xml);
+}
+
+
+$host = "localhost";
+$port = 12345;
+
+$moduleName = "PAC";
+$issueType = "Defect";
+$userName = "[email protected]";
+
+$attribs = array('Status' => 'New', 'Description' => 'Some interesting stuff from python', 'AssignedTo' => $userName);
+
+$req = xmlrpc_encode_request('newTicket.createNewTicket', array($moduleName, $issueType, $userName, $attribs));
+echo $req, "\n";
+
+$resp = do_call($host, $port, $req);
+
+echo $resp, "\n";
+
+
+?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.