What is "openssl_decrypt" in Python? - python

I got this code from some 3rd party, the purpose is to "decrypt" an encrypted data (basically just customer's name data). But i don't know what is openssl_decrypt() in Python.
The PHP code i got:
<?php
$secret = "079423bc31698dbaf2d6f49973301b97";
$content = "+oY3RKkVzstJjpaBz523z9960f/KKNfV1hrYW9bUVJ0AMwwQQfa0Zi09VH3WGac8qPpZkRodMxBIMl7suYD8ck95JI4K1mnO84nacf9sh0y8577N0zYWfhaIaapiFi/ZbX3J0aJr3gMjSk+/fIjXw99kTjZEEyDtvqyvc8K8XDaa4uQbAz10Vpf61+6I7cPKfXmdWUD53ZLweoLQZfLhnH1XK3bheX6SKRR33N/NzEwE/qbaANs2f6OL7HhjyiR58BEjg+At9c26pD5n170JoadgKVjsLZk0L2+2zMJKHuxnjtm8KxqimObZB2riIXmobA2tZmQQBx2CQGwDeqeUkxbO+uxxfb4sWKeViU90QpfDNqCTELiTkS0KnVpadzSt908rdx7w3lFuIDbqZXwClutORdASz2s1t856aLnT89UT1Tm25MWcX0kAGIaw8xYwOdoUEyk0g+4d0ZVcGUDFlU2L/8mQ9jG4YTAm/9dQH57o1s+2wTuRpmltdhAXVA==";
$bcontent = base64_decode($content);
$bnonce = substr($bcontent, strlen($bcontent) - 12, strlen($bcontent));
$bcipher = substr($bcontent, 0, strlen($bcontent) - 12);
// default tag
$taglength = 16;
$tag = substr($bcipher, strlen($bcipher) - $taglength, strlen($bcipher));
$acipher = substr($bcipher, 0, strlen($bcipher) - $taglength);
$result = openssl_decrypt( $acipher, "aes-256-gcm", $secret, OPENSSL_RAW_DATA, $bnonce, $tag);
echo $result;
?>
This is the python equivalent that i tried to replicate (the code above):
import base64
secret = "079423bc31698dbaf2d6f49973301b97";
content = "+oY3RKkVzstJjpaBz523z9960f/KKNfV1hrYW9bUVJ0AMwwQQfa0Zi09VH3WGac8qPpZkRodMxBIMl7suYD8ck95JI4K1mnO84nacf9sh0y8577N0zYWfhaIaapiFi/ZbX3J0aJr3gMjSk+/fIjXw99kTjZEEyDtvqyvc8K8XDaa4uQbAz10Vpf61+6I7cPKfXmdWUD53ZLweoLQZfLhnH1XK3bheX6SKRR33N/NzEwE/qbaANs2f6OL7HhjyiR58BEjg+At9c26pD5n170JoadgKVjsLZk0L2+2zMJKHuxnjtm8KxqimObZB2riIXmobA2tZmQQBx2CQGwDeqeUkxbO+uxxfb4sWKeViU90QpfDNqCTELiTkS0KnVpadzSt908rdx7w3lFuIDbqZXwClutORdASz2s1t856aLnT89UT1Tm25MWcX0kAGIaw8xYwOdoUEyk0g+4d0ZVcGUDFlU2L/8mQ9jG4YTAm/9dQH57o1s+2wTuRpmltdhAXVA==";
bcontent = str(base64.b64decode(content),"utf-8");
bnonce = bcontent[len(bcontent) - 12:len(bcontent) - 12 + len(bcontent)];
bcipher = bcontent[0:0 + len(bcontent) - 12];
# default tag
taglength = 16;
tag = bcipher[len(bcipher) - taglength:len(bcipher) - taglength + len(bcipher)];
acipher = bcipher[0:0 + len(bcipher) - taglength];
#####
# I don't know what is the openssl_decrypt in Python. ^_^
#####
result = openssl_decrypt(acipher, "aes-256-gcm", secret, 1, bnonce, tag);
print(result,end="");

Related

I am having problem calculating DiNapoli Stochastic Indicator with Python

Like I said I think I found a working strategy tested it in Tradingview worked pretty well actually but I just can't find any python code that calculates DiNapoli Stochastic Indicator.
I have the math formula, some pinescript and mq4 code if anyone can help me with this I think he/she will be the first in the entire internet .
Pinescript Code:
//#author LazyBear
study("DiNapoli Preferred Stochastic Oscillator [LazyBear]", shorttitle="DPSTOCH_LB" , overlay=false)
fk =input(8, title="Fast K")
sk =input(3, title="Slow K")
sd =input(3, title="Slow D")
min_ = lowest(low, fk)
max_ = highest(high, fk)
fast = (close - min_)/(max_ - min_)*100
r = nz(r[1]) + (fast - nz(r[1]))/sk
s = nz(s[1]) + (r - nz(s[1]))/sd
ob=hline(70, title="OBLevel"), os=hline(30, title="OSLevel"), fill(ob,os, gray)
plot(r, color=blue, title="Dinapoli Stoch"), plot(s, color=red, title="Signal")
Lua Code
function Init()
indicator:name("Bigger timeframe Dinapoli Preferred Stochastic");
indicator:description("");
indicator:requiredSource(core.Bar);
indicator:type(core.Oscillator);
indicator.parameters:addGroup("Calculation");
indicator.parameters:addGroup("Calculation");
indicator.parameters:addInteger("K","Number of periods for %K", "", 10, 2, 1000);
indicator.parameters:addInteger("SD", "%D slowing periods", "", 5, 2, 1000);
indicator.parameters:addInteger("D", "Number of periods for %D", "", 5, 2, 1000);
indicator.parameters:addString("BS", "Time frame to calculate stochastic", "", "D1");
indicator.parameters:setFlag("BS", core.FLAG_PERIODS);
indicator.parameters:addGroup("Display");
indicator.parameters:addColor("K_color", "Color of K", "Color of K", core.rgb(0, 255, 0));
indicator.parameters:addColor("D_color", "Color of D", "Color of D", core.rgb(255, 0, 0));
indicator.parameters:addInteger("Kwidth", "K Line Width", "", 1, 1, 5);
indicator.parameters:addInteger("Kstyle", "K Line Style", "", core.LINE_SOLID);
indicator.parameters:setFlag("Kstyle", core.FLAG_LEVEL_STYLE);
indicator.parameters:addInteger("Dwidth", "D Line Width", "", 1, 1, 5);
indicator.parameters:addInteger("Dstyle", "D Line Style", "", core.LINE_SOLID);
indicator.parameters:setFlag("Dstyle", core.FLAG_LEVEL_STYLE);
end
local source; -- the source
local bf_data = nil; -- the high/low data
local k;
local d;
local sd;
local BS;
local bf_length; -- length of the bigger frame in seconds
local dates; -- candle dates
local host;
local Stochastic;
local SK, SD;
local day_offset;
local week_offset;
local extent;
function Prepare(nameOnly)
source = instance.source;
host = core.host;
day_offset = host:execute("getTradingDayOffset");
week_offset = host:execute("getTradingWeekOffset");
BS = instance.parameters.BS;
k = instance.parameters.K;
sd = instance.parameters.SD;
d = instance.parameters.D;
assert(core.indicators:findIndicator("DINAPOLI PREFERRED STOCHASTIC") ~= nil, "Please, download and install DINAPOLI PREFERRED STOCHASTIC.LUA indicator");
extent = ( k + sd + d) * 2;
local s, e, s1, e1;
s, e = core.getcandle(source:barSize(), core.now(), 0, 0);
s1, e1 = core.getcandle(BS, core.now(), 0, 0);
assert ((e - s) < (e1 - s1), "The chosen time frame must be bigger than the chart time frame!");
bf_length = math.floor((e1 - s1) * 86400 + 0.5);
local name = profile:id() .. "(" .. source:name() .. "," .. BS .. "," .. k .. "," .. sd .. "," .. d .. ")";
instance:name(name);
if nameOnly then
return;
end
SK = instance:addStream("K", core.Line, name .. ".K", "K", instance.parameters.K_color, 0);
SK:setWidth(instance.parameters.Kwidth);
SK:setStyle(instance.parameters.Kstyle);
SD = instance:addStream("D", core.Line, name .. ".D", "D", instance.parameters.D_color, 0);
SD:setWidth(instance.parameters.Dwidth);
SD:setStyle(instance.parameters.Dstyle);
SK:addLevel(20);
SK:addLevel(50);
SK:addLevel(80);
SK:setPrecision(math.max(2, instance.source:getPrecision()));
SD:setPrecision(math.max(2, instance.source:getPrecision()));
end
local loading = false;
local loadingFrom, loadingTo;
local pday = nil;
-- the function which is called to calculate the period
function Update(period, mode)
-- get date and time of the hi/lo candle in the reference data
local bf_candle;
bf_candle = core.getcandle(BS, source:date(period), day_offset, week_offset);
-- if data for the specific candle are still loading
-- then do nothing
if loading and bf_candle >= loadingFrom and (loadingTo == 0 or bf_candle <= loadingTo) then
return ;
end
-- if the period is before the source start
-- the do nothing
if period < source:first() then
return ;
end
-- if data is not loaded yet at all
-- load the data
if bf_data == nil then
-- there is no data at all, load initial data
local to, t;
local from;
if (source:isAlive()) then
-- if the source is subscribed for updates
-- then subscribe the current collection as well
to = 0;
else
-- else load up to the last currently available date
t, to = core.getcandle(BS, source:date(period), day_offset, week_offset);
end
from = core.getcandle(BS, source:date(source:first()), day_offset, week_offset);
SK:setBookmark(1, period);
-- shift so the bigger frame data is able to provide us with the stoch data at the first period
from = math.floor(from * 86400 - (bf_length * extent) + 0.5) / 86400;
local nontrading, nontradingend;
nontrading, nontradingend = core.isnontrading(from, day_offset);
if nontrading then
-- if it is non-trading, shift for two days to skip the non-trading periods
from = math.floor((from - 2) * 86400 - (bf_length * extent) + 0.5) / 86400;
end
loading = true;
loadingFrom = from;
loadingTo = to;
bf_data = host:execute("getHistory", 1, source:instrument(), BS, loadingFrom, to, source:isBid());
Stochastic = core.indicators:create("DINAPOLI PREFERRED STOCHASTIC", bf_data, k, sd, d);
return ;
end
-- check whether the requested candle is before
-- the reference collection start
if (bf_candle < bf_data:date(0)) then
SK:setBookmark(1, period);
if loading then
return ;
end
-- shift so the bigger frame data is able to provide us with the stoch data at the first period
from = math.floor(bf_candle * 86400 - (bf_length * extent) + 0.5) / 86400;
local nontrading, nontradingend;
nontrading, nontradingend = core.isnontrading(from, day_offset);
if nontrading then
-- if it is non-trading, shift for two days to skip the non-trading periods
from = math.floor((from - 2) * 86400 - (bf_length * extent) + 0.5) / 86400;
end
loading = true;
loadingFrom = from;
loadingTo = bf_data:date(0);
host:execute("extendHistory", 1, bf_data, loadingFrom, loadingTo);
return ;
end
-- check whether the requested candle is after
-- the reference collection end
if (not(source:isAlive()) and bf_candle > bf_data:date(bf_data:size() - 1)) then
SK:setBookmark(1, period);
if loading then
return ;
end
loading = true;
loadingFrom = bf_data:date(bf_data:size() - 1);
loadingTo = bf_candle;
host:execute("extendHistory", 1, bf_data, loadingFrom, loadingTo);
return ;
end
Stochastic:update(mode);
local p;
p = core.findDate (bf_data, bf_candle, true);
if p == -1 then
return ;
end
if Stochastic:getStream(0):hasData(p) then
SK[period] = Stochastic:getStream(0)[p];
end
if Stochastic:getStream(1):hasData(p) then
SD[period] = Stochastic:getStream(1)[p];
end
end
-- the function is called when the async operation is finished
function AsyncOperationFinished(cookie)
local period;
pday = nil;
period = SK:getBookmark(1);
if (period < 0) then
period = 0;
end
loading = false;
instance:updateFrom(period);
end
Addendum: https://ninjatrader.com/support/forum/forum/ninjascript-file-sharing/ninjascript-file-sharing-discussion/3545-dinapoli-stochastic/page2

Is there a way to create a file with python, containing accentuated letters, and read that with C#?

I can create files with C#, with accentuated letters in their name and content:
string itemtoorder = itemorderitemlist.SelectedItem.ToString();
int amounttoorder = int.Parse(itemorderamount.Text);
if (unitselect.Text == "gramm")
{
amounttoorder /= 1000;
}
DateTime noww = DateTime.Now;
int result = DateTime.Compare(dateTimePicker2.Value, noww);
if (result <= 0)
{
notifyIcon1.BalloonTipText = "Nem adhatsz fel a múltba rendelést!";
notifyIcon1.Icon = new Icon("Error.ico");
}
else
{
string today = DateTime.Today.ToString().Replace(" ", "").Replace("0:00:00", "");
string selecteddateasstring = dateTimePicker2.Value.Date.ToString().Replace(" ", "").Replace("0:00:00", "");
string[] writethingie = { itemtoorder, amounttoorder.ToString(), unitselect.Text, today,
selecteddateasstring, "M" };
string path = "data\\itemorders\\" + selecteddateasstring + "_" + itemtoorder + ".txt";
if (File.Exists(path))
{
DialogResult dialogResult = MessageBox.Show("Már van ugyanilyen rendelés ugyanerre a napra.", "Hozzáadjam a rendelt mennyiséget?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
string[] dataaaa = File.ReadAllLines(path);
dataaaa[1] = (int.Parse(dataaaa[1]) + amounttoorder).ToString();
File.WriteAllLines(path, dataaaa);
notifyIcon1.BalloonTipText = "A rendelés sikeresen ki lett bővítve!";
}
else if (dialogResult == DialogResult.No)
{
notifyIcon1.BalloonTipText = "Rendelés elvetve!";
}
}
else
{
File.WriteAllLines(path, writethingie);
notifyIcon1.Icon = new Icon("order.ico");
notifyIcon1.BalloonTipText = "Sikeres rendelésfelvétel!";
}
}
I can read the file in C#, that I created. It all works.
The problem is that if I create test data with a python script:
from datetime import datetime
from random import randrange
from datetime import timedelta
import string
def randomitem():
itemlist = [
"Ananász kocka (fagyasztott)",
"Barna rizsliszt",
"Barnarizs - Nagykun (szárazon)",
"Csicseriborsó (szárazon)",
"Csirkecomb filé (Bőr nélkül)",
"Hámozott paradicsom konzerv - Petti",
"Kukorica (morzsolt, fagyasztott)",
"Marhacomb (fagyasztott)",
"Pritamin paprika (fagyasztott)",
"Sárgarépa csík (fagyasztott)",
"Sárgarépa karika (fagyasztott)",
"Sűrített paradicsom - Aranyfácán",
"Vörösbab (szárazon)",
"Vöröshagyma kocka (fagyasztott)",
"Zeller (fagyasztott, csíkozott)",
]
return(itemlist[randrange(len(itemlist))])
def randomitem2():
itemlist = [
"Ananász SŰRÍTMÉNY",
"Citrom SŰRÍTMÉNY",
"Kókuszolaj - Barco",
"Kókusztejszín - RealThai",
]
return(itemlist[randrange(len(itemlist))])
def random_date(start, end):
delta = end - start
int_delta = (delta.days * 24 * 60 * 60) + delta.seconds
random_second = randrange(int_delta)
return start + timedelta(seconds=random_second)
def randomamount():
return randrange(10,70)
for i in range(200):
d1 = datetime.strptime('2022.1.1.', '%Y.%m.%d.')
d2 = datetime.strptime('2023.12.31.', '%Y.%m.%d.')
thida = str(random_date(d1, d2))
d3 = datetime.strptime('2021.4.1.', '%Y.%m.%d.')
d4 = datetime.strptime('2023.6.28.', '%Y.%m.%d.')
thirec = random_date(d3, d4)
if(i>160):
thisitem = randomitem2()
else:
thisitem = randomitem()
file = open(thida.replace("-",".").split()[0] + "._" + thisitem + ".txt" , "w")
file.write(thisitem + "\n")
file.write(str(randomamount()) + "\n")
if(i>160):
file.write("liter" + "\n")
else:
file.write("kilogramm" + "\n")
file.write(str(thirec + timedelta(days=4)).replace("-",".").split()[0] + "\n")
file.write(str(thirec).replace("-",".").replace(" ",".") + "\n")
file.write(thida.replace("-",".").replace(" ",".") + "\n")
Then the C# script can't read the accentuated letters.
Here's the reader:
string[] files = Directory.GetFiles("data/warehouse/");
string[] recipé = File.ReadAllLines("data/recipes/" + allines[0] + ".txt");
List<string> goodpaths = new List<string>();
List<int> goodams = new List<int>();
for (int i = 0; i < recipé.Length - 2; i += 2)
{
for (int j = 0; j < files.Length - 1; j++)
{
string cuf = Regex.Split(files[j], "._")[1];
cuf = cuf.Replace(".txt", "");
//Debug.WriteLine(recipé[i]);
//Debug.WriteLine(cuf);
if (recipé[i] == cuf)
{
//Debug.WriteLine("\n--==## Match ##==--\n");
goodpaths.Add(files[j]);
goodams.Add(int.Parse(recipé[i + 1]));
//Debug.WriteLine(files[j]);
}
}
goodpaths.Add("BREAK");
}
List<int> amos = new List<int>();
List<string> exps = new List<string>();
List<List<string>> UOT = new List<List<string>>();
string curitttttttt = "";
int counter = 0;
for (int i = 0; i < goodpaths.Count - 1; i++)
{
if (goodpaths[i] != "BREAK")
{
string[] thisisthecurrentfile = File.ReadAllLines(goodpaths[i]);
curitttttttt = thisisthecurrentfile[0];
//Debug.WriteLine(File.ReadAllLines(goodpaths[i])[0]);
amos.Add(int.Parse(thisisthecurrentfile[1]));
exps.Add(thisisthecurrentfile[5]);
}
else
{
int[] ams = amos.ToArray();
string[] exs = exps.ToArray();
int ned = goodams[counter];
int amo = int.Parse(allines[1]);
List<string>[] output = DATASET(ams, exs, ned, amo);
//Alapanyag neve
List<string> itnm = new List<string>();
itnm.Add(curitttttttt);
UOT.Add(itnm);
//Részletek
dataGridView1.ColumnCount = 1;
dataGridView1.RowCount = UOT.Count;
dataGridView1[0, counter].Value = UOT[counter][0];
counter++;
amos = new List<int>();
exps = new List<string>();
}
}
So to sum the problem:
I want to create test data with Python for a C# Windows Forms program, but the C# program can read only the files well if it creates and writes them. When the files are created by the Python script, the accentuated letters are displayed as question marks.

pandas .rolling().mean() analog in C#

I'm trying to convert the following python code which calculates ATR using EMA into C#.
def calc_atr(df, high, low, close, timeperiod=14):
df['H_L'] = df[high] - df[low]
df['H_Cp'] = abs(df[high] - df[close].shift(1))
df['L_Cp'] = abs(df[low] - df[close].shift(1))
df['TR'] = df[["H_L", "H_Cp", "L_Cp"]].max(axis=1)
df['ATR'] = df['TR'].rolling(timeperiod).mean()
for i in range(timeperiod , len(df)):
df.loc[i, 'ATR'] = (df.loc[i - 1, 'ATR'] * (timeperiod -1) + df.loc[i, 'TR']) / timeperiod
return df
This is my attempt but I'm not doing the rolling window mean correctly. I think there was a way with LINQ, but I'm not sure how.
public static void CalcAtr(this List<Candle> source, int period = 14)
{
var highs = source.Select(e => e.High).ToArray();
var lows = source.Select(e => e.Low).ToArray();
var closes = source.Select(e => e.Close).ToArray();
var atr = new decimal[source.Count];
for (int i = period; i < source.Count; i++)
{
var hl = highs[i] - lows[i];
var hcp = Math.Abs(highs[i] - closes[i - 1]);
var lcp = Math.Abs(lows[i] - closes[i - 1]);
var tr = Math.Max(hl, Math.Max(hcp, lcp));
atr[i] = (atr[i - 1] * (period - 1) + tr) / period;
}
}

AD5270 SPI potentiometer with Python

I try to use a AD5270, 20KOhm SPI potentiometer for a personal project with my Raspberry Pi 3B+. I translate some Arduino libraries code to Python language but it looks like it won't work. I can't test if the potentiometer is good value configured so I read the resistor value and always get 0 from SPI register.
Problem : I don't know if my writing is well done because I can't probe the resistor. To know if it works, I read the register and always receive 0x00. Writing and/or reading won't work.
Expect : reading what I have written.
Hardware setup :
!SYNC = CE0 = PIN24
DIN = MISO = PIN19
SDO = MOSI = PIN21
SLCK = SCLK = PIN23
with 1uF ext capacitor and 3V3 supply (from Raspberry).
The datasheet of the AD5270 is available here.
Minimalist code following the datasheet that won't work :
spi = spidev.SpiDev()
spi.open(spi_bus, spi_device_select)
spi.max_speed_hz = 50000 # Datasheet p7
spi.mode = 1 # CPOL = 0, CPHA = 1 (Datasheet p7)
# Datasheet example
data = [0x1C, 0x03]
r = spi.xfer(data)
print(r)
data = [0x05, 0x00]
r = spi.xfer(data)
print(r)
data = [0x08, 0x00]
r = spi.xfer(data)
print(r)
data = [0xC0, 0x00]
r = spi.xfer(data)
print(r)
From your hardware setup:
DIN = MISO = PIN21 (through 10 Ohm resistor)
SDO = MOSI = PIN19 (through 10 Ohm resistor)
DIN is input to AD5270, and therefore output of your RPI, so it should be MOSI. Same problem for SDO.
I finally got the tricks. Don't forget to add a pullup on SDO line and configure Spidev for the AD5270. This code work quite well :
# SPI test code for AD5270BRMZ-20
import time
import spidev
spi_bus = 0 # SPI0
spi_device_select = 0 # CE0
spi = spidev.SpiDev()
spi.open(spi_bus, spi_device_select)
spi.max_speed_hz = 50000 # Datasheet p7
spi.mode = 1 # CPOL = 0, CPHA = 1 (Datasheet p7)
spi.lsbfirst = False # Datasheet p18
MAX_RESISTANCE = 20000.0
WRITE_CTRL_REG = 0x1C
READ_CTRL_REG = 0x20
WRITE_RDAC = 0x04
READ_RDAC = 0x08
RDAC_WRITE_PROTECT = 0x02
def AD5270_CalcRDAC(resistance):
return int((resistance / MAX_RESISTANCE) * 1024.0)
def AD5270_ReadReg(command):
data = [(command & 0x3C), 0]
r = spi.xfer2(data)
data = [0x00, 0x00]
r2 = spi.xfer2(data)
result = r2[0]
result = (result << 8) | r2[1]
return result
def AD5270_WriteReg(command, value):
ui16Command = (command & 0x3C) << 8 | (value & 0x3FF)
data = [(ui16Command >> 8) & 0xFF, ui16Command & 0xFF]
spi.xfer2(data)
def AD5270_ReadRDAC():
RDAC_val = AD5270_ReadReg(READ_RDAC)
RDAC_val &= 0x03FF
return ((RDAC_val) * MAX_RESISTANCE) / 1024.0
def AD5270_WriteRDAC(resistance):
RDAC_val = AD5270_CalcRDAC(resistance)
spi.xfer2([WRITE_CTRL_REG, RDAC_WRITE_PROTECT])
AD5270_WriteReg(WRITE_RDAC, RDAC_val);
return ((RDAC_val * MAX_RESISTANCE) / 1024.0)
while(1):
AD5270_WriteRDAC(10000.0) # Write 10KOhm
print(AD5270_ReadRDAC())
time.sleep(1)
spi.close()

python - transform a C# method in python method

I'm new in Python and I trying to make this C# method
protected void read(){
string[] attributes = new string[16];
attributes[0] = "ref_num";
attributes[1] = "tenant.name";
attributes[2] = "request_by.first_name";
attributes[3] = "request_by.first_name";
attributes[4] = "customer.first_name";
attributes[5] = "customer.last_name";
attributes[6] = "customer.id";
attributes[7] = "category.sym";
attributes[8] = "status.sym";
attributes[9] = "group.last_name";
attributes[10] = "zreporting_met.sym";
attributes[11] = "assignee.combo_name";
attributes[12] = "open_date";
attributes[13] = "close_date";
attributes[14] = "description";
attributes[15] = "summary";
int sid = soap.login("user", "pass");
string objectType = "cr";
string whereClause = "ref_num = '15967'";
int maxRows = -1;
//Valor de tiempo en Epoch
var epoch = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
//Transforma en valor de fecha humana
string _epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(epoch).ToShortDateString();
ArrayList resultado = new ArrayList();
XmlDocument xml = new XmlDocument();
try
{
string _selectResponse = soap.doSelect(sid, objectType, whereClause, maxRows, attributes);
xml.LoadXml(_selectResponse);
XmlNodeList nodeList = xml.GetElementsByTagName("AttrValue");
for (int i = 0; i < nodeList.Count; i++)
{
resultado.Add(nodeList[i].InnerXml);
}
soap.logout(sid);
}
catch (Exception l)
{
Console.Write(l.Message);
}
}
this method works perfectly, in python I have this for the moment
class WebService:
soap = 'webservice url'
client = Client(soap)
sid = client.service.login("user","pass")
attributes = ["ref_num", "open_date"]
objectType = "cr"
whereClause = "open_date > 1519862400 AND open_date < 1522368000"
maxRows = -1
tickets = client.service.doSelect(sid, objectType, whereClause, -1, attributes)
print(tickets)
logout = client.service.logout(p)
using zeep to connect to the Web Service
the error what I have is in attributes array, the login method, works but when I try to use doSelect() method it says:
zeep.exceptions.ValidationError: Missing element string (doSelect.attributes)
Someone can help me? Thanks in advance.

Categories