<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: alokkumarsbg</title>
    <description>The latest articles on DEV Community by alokkumarsbg (@alokkumarsbg).</description>
    <link>https://dev.to/alokkumarsbg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F478204%2F932ac6f4-45ea-483d-a2e0-5ce39dacf464.jpg</url>
      <title>DEV Community: alokkumarsbg</title>
      <link>https://dev.to/alokkumarsbg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alokkumarsbg"/>
    <language>en</language>
    <item>
      <title>Talking bot "You have got a Ticket"</title>
      <dc:creator>alokkumarsbg</dc:creator>
      <pubDate>Fri, 16 Oct 2020 07:37:09 +0000</pubDate>
      <link>https://dev.to/alokkumarsbg/talking-bot-you-have-got-a-ticket-1ife</link>
      <guid>https://dev.to/alokkumarsbg/talking-bot-you-have-got-a-ticket-1ife</guid>
      <description>&lt;p&gt;I being a Support Engineer, one of the tough jobs is to regularly monitor the Case or Ticket tool for new case or Ticket.&lt;/p&gt;

&lt;p&gt;What if you have a bot saying &lt;strong&gt;"Hey Man you have got a new ticket"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;How exciting and relaxing will be! I am really excited about that. This saves me a lot of time from the boring and irritating job of Queue Monitor for the Ticket.&lt;/p&gt;

&lt;p&gt;Today I will take you the Journey how I got this done. Though I won't share any code here, Company Policy. But I will share what I have used to build this bot.&lt;/p&gt;

&lt;p&gt;I have implemented this bot on the &lt;em&gt;Service Now Ticket Management Tool&lt;/em&gt;. I have built this using the Python Language easiest programming language for a Support Engineer. &lt;/p&gt;

&lt;p&gt;I have used two Python Packages for this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Selenium&lt;/strong&gt;: One of the Most used Automation package available in Different Languages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pyttsx3&lt;/strong&gt;: Text to Speech Package for your bot to Talk.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Selenium being an Automation Tool, it can also be used to scrap a website. Basically, I have scrapped the Service Now WebPage using the Selenium to read tables which have new Ticket Details.&lt;br&gt;
I have used chrome driver to open a web page in chrome browser. Others Driver is also available for different browser. One of the other common is for Firefox "GeckoDriver"&lt;/p&gt;

&lt;p&gt;So if you are a support engineer go and try this. Make your life easier and your Manager happy.&lt;br&gt;
Because many think &lt;em&gt;"Support Engineers are not meant for Coding"&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>supportengineer</category>
    </item>
    <item>
      <title>WebHook or Reverse API</title>
      <dc:creator>alokkumarsbg</dc:creator>
      <pubDate>Sat, 03 Oct 2020 12:03:43 +0000</pubDate>
      <link>https://dev.to/alokkumarsbg/webhook-or-reverse-api-37o1</link>
      <guid>https://dev.to/alokkumarsbg/webhook-or-reverse-api-37o1</guid>
      <description>&lt;p&gt;I do some Development work as a freelancer to keep updated myself with new kinds of work apart from being a Support Engineer.&lt;/p&gt;

&lt;p&gt;I came up with work where I was to write a code where data is to be exposed as a JSON. I thought its easy work can be done quickly. But there was a tweak on the work. The code was to send as JSON to &lt;strong&gt;Webhook&lt;/strong&gt; not exposed as an API. First time I came up with the word Webhook. I checked for an hour with my teacher GOOGLE. I really liked the concept of Webhook which I like to share with all of you.&lt;/p&gt;

&lt;p&gt;WebHook or also said Reverse API is a concept where data in any format is sent to the other application POST method URL. Normally in API, we keep checking with the server for any new data in the API. But in Webhook, the server when to find any changes in data is sent to the client application.&lt;/p&gt;

&lt;p&gt;This prevents a lot of traffic onto the server, as the client doesn't have to make requests every time to check for updated data. But API has its own use. &lt;/p&gt;

&lt;p&gt;Now let's understand it through code perspective.&lt;br&gt;
First, let me make a Post Method in FLask Server that accepts a JSON file. This method will accept the code. So this will be webhook URL(&lt;a href="http://localhost/webhook"&gt;http://localhost/webhook&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/webhook"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;respond&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server end will now send the data to this URL when it's triggered using some condition. When the triggered condition is met the data will be sent to the URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="c1"&gt;# WebURL which will accept this Json file
&lt;/span&gt;&lt;span class="n"&gt;webhook_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"http://localhost/webhook"&lt;/span&gt;

&lt;span class="c1"&gt;# DB connection
&lt;/span&gt;&lt;span class="n"&gt;cnxn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db_conn&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# SQL Query. Place your own query
&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_sql_query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'''select * from sample'''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;cnxn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Convert sql result in json format
&lt;/span&gt;&lt;span class="n"&gt;json_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orient&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'records'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Send data to URL
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;triggered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;#Any condition as per your design logic
&lt;/span&gt;    &lt;span class="n"&gt;reponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;webhook_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json_response&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'Content-Type'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'application/json'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Raise Error if data send not successfull 200 code for successfull
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;reponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This Youtube link explains more about WebHook which is used in Github. Do watch this.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/YMBzb_RBDAA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Start Stop Button in Python</title>
      <dc:creator>alokkumarsbg</dc:creator>
      <pubDate>Wed, 30 Sep 2020 19:21:03 +0000</pubDate>
      <link>https://dev.to/alokkumarsbg/start-stop-button-in-python-3oik</link>
      <guid>https://dev.to/alokkumarsbg/start-stop-button-in-python-3oik</guid>
      <description>&lt;p&gt;I am a Technical Support Engineer who always quenches his thirst of coding to automate the repeating manual work. I would like to share one of the challenges that I faced while creating one such tool.&lt;/p&gt;

&lt;p&gt;I have developed a code to monitor case &amp;amp; ticket in the Ticketing Tool. One of the boring work of a support engineer. The aim was to create a UI for start and stop button which can control this ticketing tool. The UI was created using the Tkinter package.&lt;/p&gt;

&lt;p&gt;The Challenge was whenever the start button was pressed, the button won't release until the code execution of the function started using the button completes. During the search for this solution, I came across the MultiThreading.&lt;/p&gt;

&lt;p&gt;These guys saved my life. Although this common to many, coming across such thing was a thrill. &lt;/p&gt;

&lt;p&gt;Multithreading is having different thread under the same process where all threads share the same memory. So the process always has a Main Thread which is the main program and other thread which is created from Main Thread.&lt;/p&gt;

&lt;p&gt;I created a function to start_thread to start my start function as a separate thread&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;start_btn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Tk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;start_thread&lt;/span&gt;
&lt;span class="n"&gt;start_btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
 &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start_thread&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;t1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Main&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we are using Multithreading the memory is shared, so at anytime the value of status can be changed and the application can be stopped&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;stop_btn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Tk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;start_thread&lt;/span&gt;
&lt;span class="n"&gt;stop_btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
  &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I can now easily control my application a few lines of code. Though is a small thing for a coder, for me at that moment was a Saviour.&lt;/p&gt;

</description>
      <category>python</category>
      <category>threading</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
