conversion from python to lazarus lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- id_ruben · 2016-07-04 19:04 HI, How conversion of python code to  lazarus code. What components should I use. python import: import httplib import urllib import json import hashlib import hmac import time import threading import urllib2 python code 1 :   req = urllib2.Request(url=myurl)   response = urllib2.urlopen(req)   jsonString = response.read()    objFromJSON = json.loads(jsonString) python code 2 :     parms = {"param1":"vparam1","param2":"vparam2","param3":'vparam3"}        parms=urllib.urlencode(parms)           H = hmac.new(key2, digestmod=hashlib.sha512)       H.update(parms)      sign = H.hexdigest()      headers = {"Content-type": "application/x-www-form- urlencoded","Key":key1,"Sign":sign}      conn = httplib.HTTPSConnection(mysite2)      conn.request("POST", "/tapi", parms, headers)      response = conn.getresponse()      resp_1= json.load(response) * Lazarus 1.2.0 * Fedora 21 LXDE Thanks you. Ruben ---------------------------------------------------------------------- Leledumbo · 2016-07-04 20:12 classes (for TThread, although I don't see where you use it in the python code), cthreads (for unix platforms), fphttpclient, fpjson. hash package has no hmac-sha512 implementation so that will require some 3rd party lib like flcHash or RHL. Done, no components needed. ---------------------------------------------------------------------- id_ruben · 2016-07-07 19:31 Quote from: Leledumbo on July 04, 2016, 10:12:10 pmclasses (for TThread, although I don't see where you use it in the python code), cthreads (for unix platforms), fphttpclient, fpjson. hash package has no hmac-sha512 implementation so that will require some 3rd party lib like flcHash or RHL. Done, no components needed. python            lazarus       I am not sure if this is appropriate threading           ttimer python   req = urllib2.Request(url=myurl)   response = urllib2.urlopen(req) Lazarus LSHTTPGetText(myurl, strbuf) but uses fpjson, jsonparser; error in GetJSON Identifier Not Found "GetJSON" while I use " findpart " to retrieve information from "strbuf" . ---------------------------------------------------------------------- Leledumbo · 2016-07-08 08:55 Quote from: id_ruben on July 07, 2016, 09:31:32 pmpython            lazarus       I am not sure if this is appropriate threading           ttimer Well, TTimer runs on its own thread. But if the code is meant for threading, then use TThread, not TTimer. Quote from: id_ruben on July 07, 2016, 09:31:32 pmpython   req = urllib2.Request(url=myurl)   response = urllib2.urlopen(req) Lazarus LSHTTPGetText(myurl, strbuf) but uses fpjson, jsonparser; error in GetJSON Identifier Not Found "GetJSON" while I use " findpart " to retrieve information from "strbuf" . Update your FPC (and Lazarus) first. Lazarus 1.2.0 comes with FPC 2.6.2 and is more than 2 years old. GetJSON should be in fpjson unit. ---------------------------------------------------------------------- id_ruben · 2016-07-08 20:34 Quote from: Leledumbo on July 08, 2016, 10:55:20 amQuote from: id_ruben on July 07, 2016, 09:31:32 pmpython            lazarus       I am not sure if this is appropriate threading           ttimer Well, TTimer runs on its own thread. But if the code is meant for threading, then use TThread, not TTimer. Quote from: id_ruben on July 07, 2016, 09:31:32 pmpython   req = urllib2.Request(url=myurl)   response = urllib2.urlopen(req) Lazarus LSHTTPGetText(myurl, strbuf) but uses fpjson, jsonparser; error in GetJSON Identifier Not Found "GetJSON" while I use " findpart " to retrieve information from "strbuf" . Update your FPC (and Lazarus) first. Lazarus 1.2.0 comes with FPC 2.6.2 and is more than 2 years old. GetJSON should be in fpjson unit. install lazarus 1.6 fpc-3.0.0-1.i686.rpm fpc-src-3.0.0-151202.i686.rpm lazarus-1.6-0.i686.rpm simple program unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs; type   TForm1 = class(TForm)   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} end.                 Error : Compile Project, Target: /var/tmp/project1: Exit code 256, Errors: 1 lazutf8.pas(184,3) Fatal: Cannot find gettext used by LazUTF8 of package LazUtils. but if using the root , succeed Compile Project, Target: /root/tmp/project1: Success Directory FPC and FPC-src deleted  replaced with a new one. how to use Lazarus without root  ? Solved Compile Project, Target: /home/ruben/tmp/project1: Success