<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1979429918530798117</id><updated>2011-11-27T16:34:51.905-08:00</updated><category term='Asterisk'/><category term='AMIConnector'/><category term='IronPython Studio'/><category term='AMI'/><category term='IPY'/><category term='IronPython'/><category term='python'/><category term='GData API'/><category term='SharpDevelop'/><category term='Google Calendar'/><title type='text'>Application.Run()</title><subtitle type='html'>I just became a fan of Ironpython and here is my collection of thoughts, codes and problems encountered while learning the language.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ipy-codes.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ipy-codes.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dennis Nacino</name><uri>http://www.blogger.com/profile/05602042574383832761</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1979429918530798117.post-4317388905133513820</id><published>2009-05-01T06:27:00.000-07:00</published><updated>2009-05-01T08:41:42.345-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IPY'/><category scheme='http://www.blogger.com/atom/ns#' term='Asterisk'/><category scheme='http://www.blogger.com/atom/ns#' term='AMI'/><category scheme='http://www.blogger.com/atom/ns#' term='AMIConnector'/><title type='text'>IPY as AMI client thru AMIConnector</title><content type='html'>One of the thing I like about IPY or python programming. If a class is professionally crafted, the info on how to use methods is readily available. On this post I explore the library &lt;a href="http://www.asteriskarena.com/index.php/en/utilities/amiconnector"&gt;AMIConnector&lt;/a&gt;. &lt;br /&gt;An access to AMI(Asterisk Manager Interface) is needed to run a script that uses this library. But since I have no Asterisk access whatsoever, I will be contended exploring the methods use to originate a call.  &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt; import clr&lt;br /&gt;&gt;&gt;&gt; clr.AddReferenceToFileAndPath("C:\IronPython 2.0.1\Lib\site-packages\AMI.Con&lt;br /&gt;nector.14.dll")&lt;br /&gt;&gt;&gt;&gt; import AMI_Connector_14.AMI_Connector as Ami14&lt;br /&gt;&gt;&gt;&gt; dir(Ami14)&lt;br /&gt;['ActionResponse_ExtensionState', 'ActionResponse_ExtensionStateEventHandler', '&lt;br /&gt;Action_AgentCallBackLogin', 'Action_AgentLogoff', 'Action_ExtensionState', 'Acti&lt;br /&gt;on_HangUp', 'Action_Originate', 'Action_ParkedCalls', 'Action_QueueAdd', 'Action&lt;br /&gt;_QueuePause', 'Action_QueueRemove', 'Action_QueueStatus', 'Action_Redirect', 'Ag&lt;br /&gt;ents', 'AsteriskVersion', 'CanRaiseEvents', 'Connect', 'Connected', 'Container',&lt;br /&gt; 'CreateObjRef', 'DesignMode', 'Disconnect', 'Disconnected', 'DisconnectedEventH&lt;br /&gt;andler', 'Dispose', 'Disposed', 'Equals', 'Evaluation', 'Event_Agents', 'Event_A&lt;br /&gt;gentsComplete', 'Event_AgentsCompleteEventHandler', 'Event_AgentsEventHandler',&lt;br /&gt;'Event_Cdr', 'Event_CdrEventHandler', 'Event_Dial', 'Event_DialEventHandler', 'E&lt;br /&gt;vent_ExtensionStatus', 'Event_ExtensionStatusEventHandler', 'Event_HangUp', 'Eve&lt;br /&gt;nt_HangUpEventHandler', 'Event_Join', 'Event_JoinEventHandler', 'Event_Leave', '&lt;br /&gt;Event_LeaveEventHandler', 'Event_Link', 'Event_LinkEventHandler', 'Event_Login',&lt;br /&gt; 'Event_LoginEventHandler', 'Event_MeetmeJoin', 'Event_MeetmeJoinEventHandler',&lt;br /&gt;'Event_MeetmeLeave', 'Event_MeetmeLeaveEventHandler', 'Event_MeetmeStopTalking',&lt;br /&gt; 'Event_MeetmeStopTalkingEventHandler', 'Event_MeetmeTalking', 'Event_MeetmeTalk&lt;br /&gt;ingEventHandler', 'Event_MusicOnHold', 'Event_MusicOnHoldEventHandler', 'Event_N&lt;br /&gt;ewChannel', 'Event_NewChannelEventHandler', 'Event_NewState', 'Event_NewStateEve&lt;br /&gt;ntHandler', 'Event_Newcallerid', 'Event_NewcalleridEventHandler', 'Event_Newexte&lt;br /&gt;n', 'Event_NewextenEventHandler', 'Event_ParkedCall', 'Event_ParkedCallEventHand&lt;br /&gt;ler', 'Event_PeerStatus', 'Event_PeerStatusEventHandler', 'Event_QueueMember', '&lt;br /&gt;Event_QueueMemberAdded', 'Event_QueueMemberAddedEventHandler', 'Event_QueueMembe&lt;br /&gt;rEventHandler', 'Event_QueueMemberPaused', 'Event_QueueMemberPausedEventHandler'&lt;br /&gt;, 'Event_QueueMemberRemoved', 'Event_QueueMemberRemovedEventHandler', 'Event_Que&lt;br /&gt;ueMemberStatus', 'Event_QueueMemberStatusEventHandler', 'Event_QueueParams', 'Ev&lt;br /&gt;ent_QueueParamsEventHandler', 'Event_QueueStatusComplete', 'Event_QueueStatusCom&lt;br /&gt;pleteEventHandler', 'Event_Registry', 'Event_RegistryEventHandler', 'Event_Renam&lt;br /&gt;e', 'Event_RenameEventHandler', 'Event_UnParkedCall', 'Event_UnParkedCallEventHa&lt;br /&gt;ndler', 'Event_Unlink', 'Event_UnlinkEventHandler', 'Events', 'GetHashCode', 'Ge&lt;br /&gt;tLifetimeService', 'GetService', 'GetType', 'HostIP', 'HostPort', 'InitializeLif&lt;br /&gt;etimeService', 'LicenceAmi', 'MemberwiseClone', 'ReferenceEquals', 'SearchInBloc&lt;br /&gt;k', 'SendInformation', 'Site', 'ToString', 'User', '__class__', '__delattr__', '&lt;br /&gt;__doc__', '__enter__', '__exit__', '__getattribute__', '__hash__', '__init__', '&lt;br /&gt;__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__']&lt;br /&gt;&gt;&gt;&gt; dir(Ami14.Connect)&lt;br /&gt;['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToSt&lt;br /&gt;ring', '__call__', '__class__', '__cmp__', '__delattr__', '__delete__', '__doc__&lt;br /&gt;', '__get__', '__getattribute__', '__hash__', '__init__', '__name__', '__new__',&lt;br /&gt; '__objclass__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__st&lt;br /&gt;r__']&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Of course it will be really difficult if you have no API documents (no examples) or knowledge what's the library all about. In my case, I'm an Asterisk fan way back 2003. So its pretty easy for me how to make this script connect and place(originate) a call.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&gt;&gt;&gt; Ami14.HostIP.__doc__&lt;br /&gt;'Get: str HostIP(self)\r\nSet: HostIP(self) = value\r\n'&lt;br /&gt;&gt;&gt;&gt; Ami14.HostPort.__doc__&lt;br /&gt;'Get: str HostPort(self)\r\nSet: HostPort(self) = value\r\n'&lt;br /&gt;&gt;&gt;&gt; Ami14.Connect.__doc__&lt;br /&gt;'Connect(self, str UserAMI, str PasswordAMI)'&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above code is straightforward its use to connect to the AMI. While the two method below places the call and ultimately disconnect the script from AMI. &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&gt;&gt;&gt; Ami14.Action_Originate.__doc__&lt;br /&gt;'Action_Originate(self, str Channel, str Context, str Exten, str CallerID)'&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&gt;&gt;&gt; Ami14.Disconnect.__doc__&lt;br /&gt;'Disconnect(self)'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;On the next post I will do form and actual codes that uses AMIConnector library.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1979429918530798117-4317388905133513820?l=ipy-codes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ipy-codes.blogspot.com/feeds/4317388905133513820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ipy-codes.blogspot.com/2009/05/ipy-as-ami-client-thru-amiconnector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default/4317388905133513820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default/4317388905133513820'/><link rel='alternate' type='text/html' href='http://ipy-codes.blogspot.com/2009/05/ipy-as-ami-client-thru-amiconnector.html' title='IPY as AMI client thru AMIConnector'/><author><name>Dennis Nacino</name><uri>http://www.blogger.com/profile/05602042574383832761</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1979429918530798117.post-7031273418940785753</id><published>2009-03-19T00:26:00.000-07:00</published><updated>2009-03-25T06:33:23.083-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GData API'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Calendar'/><category scheme='http://www.blogger.com/atom/ns#' term='IronPython'/><title type='text'>IPY with Google Data Calendar API</title><content type='html'>Here's a code that I've done while learning the language. In this python code I explored the Google Calendar through its API. Creating an instance of the service,&lt;a href="http://code.google.com/apis/calendar/docs/2.0/developers_guide_dotnet.html#AuthClientLogin"&gt;ClientLogin&lt;/a&gt; and retrieving entries were pretty much straightforward. But creating,updating and deleting calendar's event(or entries) really took me sometime to make it work. On creating entries, I had a hard time coding the this &lt;blockquote&gt;Insert(TEntry)(Uri, TEntry)&lt;/blockquote&gt; to python. It took a help from IPY mailing list to get on with my programming. On updating and deleting entries, I thought it would be straightforward but it's not. But, anyway I figured it out how to delete or update entries. &lt;br /&gt;&lt;br /&gt;Below is the class that explore the Google Calendar.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;class googleCal:&lt;br /&gt;        &lt;br /&gt;    def __init__(self,googleacct,googlepasswd):&lt;br /&gt;        "Login to google"&lt;br /&gt;        self.calsvc = GDCal.CalendarService("myapp")&lt;br /&gt;        self.calsvc.setUserCredentials(googleacct,googlepasswd)     &lt;br /&gt;        return self.calsvc&lt;br /&gt;    def doentries(self,myURL,date2post,myTitle,myContent):    &lt;br /&gt;        # define srch range for retrieval&lt;br /&gt;        postdate = DateTime.Parse(date2post)&lt;br /&gt;        myQuery = GDCal.EventQuery(myURL)&lt;br /&gt;        myQuery.StartTime = postdate&lt;br /&gt;        myQuery.EndTime = postdate.AddMinutes(1438)&lt;br /&gt;        myevFeed = self.calsvc.Query(myQuery)&lt;br /&gt;        &lt;br /&gt;        if myevFeed.Entries.Count &gt; 0:&lt;br /&gt;            for myentry in myevFeed.Entries:&lt;br /&gt;                # first entry and only entry need to update or delete&lt;br /&gt;                print "Old Entry: " + myentry.Title.Text&lt;br /&gt;                ###########################################################&lt;br /&gt;                # to delete entry&lt;br /&gt;                #myentry.Delete                                 &lt;--- not working&lt;br /&gt;                ###########################################################&lt;br /&gt;                self.calsvc.Delete(myentry)&lt;br /&gt;                print "Succesfully deleted\n"&lt;br /&gt;                ############################################################&lt;br /&gt;                # to update entry&lt;br /&gt;                #myentry.Title.Text = myTitle&lt;br /&gt;                #myentry.Content.Content = myContent&lt;br /&gt;                #myentry.Update                           &lt;-- not working&lt;br /&gt;                #self.mycalsvc.Update[type(myentry)](myentry)  &lt;-- working&lt;br /&gt;                ############################################################&lt;br /&gt;                break&lt;br /&gt;        else:&lt;br /&gt;         pass&lt;br /&gt;&lt;br /&gt;        # delete and create that's the idea not update&lt;br /&gt;        myentry = GDCal.EventEntry()&lt;br /&gt;        myUri = Uri(myURL)&lt;br /&gt;        myentry.Title.Text = myTitle        &lt;br /&gt;        myentry.Content.Content = myContent&lt;br /&gt;        if DateTime.Compare(postdate,DateTime.Today) == 0:&lt;br /&gt;            evWhento = DateTime.Now&lt;br /&gt;        else:&lt;br /&gt;            evWhento = postdate.AddHours(22)&lt;br /&gt;        evTime = GDxtn.When(evWhento,evWhento.AddMinutes(60))&lt;br /&gt;        myentry.Times.Add(evTime)&lt;br /&gt;        self.calsvc.Insert[type(myentry)](myUri,myentry)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and the rest of the code that uses the class&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;if len(sys.argv) &lt; 2:&lt;br /&gt;    dtofs = 0&lt;br /&gt;else:&lt;br /&gt;    dtofs = int(sys.argv[1])&lt;br /&gt;    &lt;br /&gt;mydate = CDRdate(dtofs)&lt;br /&gt;print "Date: " + mydate.rtndate()&lt;br /&gt;CDR = getCDR(mydate.rtndate())&lt;br /&gt;sfields = CDR.rtnCDR()&lt;br /&gt;eTitle = "Dumb Bill: $%3.2f" % sfields[2]&lt;br /&gt;eContent = "CallCount: %d\nTotalLength: %d:%d\nBill: $%3.2f\n" % (sfields[0],(sfields[1]/60),(sfields[1]%60),sfields[2])&lt;br /&gt;feedURL = "http://www.google.com/calendar/feeds/sometext here%40group.calendar.google.com/private/full" &lt;br /&gt;print eTitle&lt;br /&gt;print eContent&lt;br /&gt;gcalsvc = googleCal(username here,password here)&lt;br /&gt;gcalsvc.doentries(feedURL,mydate.rtndate(),eTitle,eContent)&lt;br /&gt;print "New Entry: " + eTitle&lt;br /&gt;print "Successfully Inserted\n"&lt;/pre&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1979429918530798117-7031273418940785753?l=ipy-codes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ipy-codes.blogspot.com/feeds/7031273418940785753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ipy-codes.blogspot.com/2009/03/ipy-with-google-data-calendar-api.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default/7031273418940785753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default/7031273418940785753'/><link rel='alternate' type='text/html' href='http://ipy-codes.blogspot.com/2009/03/ipy-with-google-data-calendar-api.html' title='IPY with Google Data Calendar API'/><author><name>Dennis Nacino</name><uri>http://www.blogger.com/profile/05602042574383832761</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1979429918530798117.post-5967119342897708757</id><published>2009-03-12T07:15:00.000-07:00</published><updated>2009-03-13T20:22:21.461-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharpDevelop'/><category scheme='http://www.blogger.com/atom/ns#' term='IronPython'/><category scheme='http://www.blogger.com/atom/ns#' term='IronPython Studio'/><title type='text'>IronPython Studio and SD</title><content type='html'>Both product were great but both have bug (as of this writing) that makes wannabe pythonistas or pythoneers life difficult.&lt;br /&gt;&lt;br /&gt;In my experience, &lt;span style="font-weight:bold;"&gt;IP Studio&lt;/span&gt; in the middle of coding and debugging will eventually reset the design form to just blank form. Double clicking on the blank form erases my codes.&lt;br /&gt;&lt;br /&gt;On &lt;span style="font-weight:bold;"&gt;SharpDevelop&lt;/span&gt;, I could live without a design tab. But, not with this &lt;a href="http://community.sharpdevelop.net/forums/t/9183.aspx"&gt;&lt;span style="font-weight:bold;"&gt;bug&lt;/span&gt;&lt;/a&gt;. It took me sometimes to figure out that there's nothing wrong with my codes by running it from the commandline. &lt;br /&gt;&lt;br /&gt;With these bugs how other pythonistas does it? Me, I rely on IP Studio to generate all codes related to the form. Or just cut and paste the codes I found on the web to make thing more easier. Then run it from the commandline, let alone the ipy check for errors.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1979429918530798117-5967119342897708757?l=ipy-codes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ipy-codes.blogspot.com/feeds/5967119342897708757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ipy-codes.blogspot.com/2009/03/ironpython-studio-and-sd.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default/5967119342897708757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1979429918530798117/posts/default/5967119342897708757'/><link rel='alternate' type='text/html' href='http://ipy-codes.blogspot.com/2009/03/ironpython-studio-and-sd.html' title='IronPython Studio and SD'/><author><name>Dennis Nacino</name><uri>http://www.blogger.com/profile/05602042574383832761</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
