AttributeError: 'dict' object has no attribute 'startEditing' - pyqgis

Good morning, I'm new to pyqgis.
I'm trying to create a new field in my attribute table but it's not working if someone can help me I appreciate it
follow the code:
# Calculadora de campo
alg_params = {
'FIELD_LENGTH': 0,
'FIELD_NAME': 'campo1',
'FIELD_PRECISION': 0,
'FIELD_TYPE': 1, # Número inteiro
'FORMULA': ' $id ',
'INPUT': parameters['entrecomacamada'],
'OUTPUT': parameters['Saida']
}
outputs = processing.run('native:fieldcalculator', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
results['Saida'] = outputs
**results.startEditing()
results.addAttribute(QgsFiel('campo1'),QVariant.String)
results.commitChanges()**
return results

Related

CL_HTPP_CLIENT CODE 400 BAD REQUEST - ABAP

i am trying to Post a Json to a Web Service.
The connection is good , but Unfortunately the payload arrives empty to the other side.
The Variable Jsondata is not empty and is a string.
I dont know what is missing. I have another Service to another api with a small json and works well.
Call Method cl_http_client=>create_by_url
Exporting
url = url
Importing
client = client
Exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
Others = 4.
If Sy-Subrc Ne 0.
Raise Error_conexion_token.
Else.
.
Data(Bearer) = 'Bearer' && | | && token.
client->request->set_header_field(
Exporting
name = 'Authorization'
value = Bearer ).
client->request->set_header_field(
Exporting
Name = 'Content-Type'
Value = 'application/json; charset=utf-8' ).
Call method client->request->set_cdata(
Exporting data = jsondata ).
client->request->set_method( if_http_request=>co_request_method_post).
Call Method client->send.
If sy-subrc Ne 0.
Raise Error_conexion_token.
Else.
Call Method client->receive
Exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
Others = 4.
If sy-subrc Ne 0.
Data(rc) = sy-subrc.
client->get_last_error(
Importing
code = zhcm_fdexperience=>codigo
message = zhcm_fdexperience=>mensaje ).
Case rc.
When 1.
Raise http_communication_failure.
When 2.
Raise http_invalid_state.
When 3.
Raise http_processing_failed.
Endcase.
Else.
client->get_last_error(
Importing
code = zhcm_fdexperience=>codigo
message = zhcm_fdexperience=>mensaje ).
Call method client->response->get_status( Importing code = zhcm_fdexperience=>codigo
reason = zhcm_fdexperience=>mensaje ).
If zhcm_fdexperience=>codigo Ne '200' Or zhcm_fdexperience=>codigo Ne '000' Or zhcm_fdexperience=>codigo Ne '0'.
Clear zhcm_fdexperience=>codigo.
Clear zhcm_fdexperience=>mensaje.
Data(Respuesta) = client->response->get_cdata( ).
Else.
Respuesta = client->response->get_cdata( ).
Endif.
Call method client->close.
An this is the json.
{
"data": [
{
"apiTipo": 1,
"fechaHoraAccion": "07/09/2021 21:20:03",
"nombreUsuarioSAP": "JUAN",
"numeroPersonal": "00001127",
"numeroPersonalREF": "sin información",
"tratamiento": "Señor",
"apellidoPaterno": "letelier",
"apellidoMaterno": "diaz",
"nombre": "rodrigo",
"sexo": "masculino",
"fechaNacimiento": "29/05/1985",
"estadoCivil": "Casado",
"nacionalidad": "Argentina",
"documentoIdentidad": "15902492-2",
"sociedad": "SBIO",
"divisionPersona": "CL01",
"centroCosto": "sin información",
"subdivisionPersona": "sin información",
"calleNumero": "ladies nIght 3221",
"ciudad": "san fernando",
"region": "Libertador Bernardo",
"pais": "Chile",
"telefono": "717846",
"claseContrato": "INDEFINIDO",
"plazoPreavEmpresa": "22.5 HORAS SEMANALES",
"reglaPlanJornadaColaborador": "BHADP201",
"statGestionTiempo": "9 - Evaluacion",
"indAdicTiempo": "NC",
"claseConvenio": "Sin Negociacion",
"areaConvenio": "No Sindicalizado",
"grupoProfesional": "General",
"subgrupoProfesional": "01",
"claseCorreoPersonal": "adiazs#funk.com",
"idSistema": "0016",
"fechaInicio": "22/08/2021",
"fechaFin": "31/12/9999"
}
]
}
Note : I tested in postman and works well.

Powershell soap using New-WebServiceProxy namespace and object issue

I'm trying to write a soap request in powershell the service is up I can request it with soapui.
After reading this and this, I don't manage to put my paramater in the ns.param object.
I don't even manage to create the ns.param object.
I try to be as much exhaustive as possible if you need more information to answer I will provide it ASAP.
I want to call this method :
search Method ns.resultats search(string login, string password, ns.entite entite, bool entiteSpecified, ns.searchCriteria criteres, bool details, bool c...
in the IDE the auto-completion show me that critere is type of ns.param[]
enter image description here
When I try to get-Member of the the $scParam variable I have an error message :
gm : Le champ ou la propriété «Value» du type «ns.param» ne diffère que par la casse du champ ou de la propriété «value». Le type doit être compatible avec la spécification CLS (Common
Language Specification).
Au caractère C:\Users\edoua\Documents\test.ps1:13 : 12
$scParam | gm
~~
CategoryInfo : NotSpecified: (:) [Get-Member], ExtendedTypeSystemException
FullyQualifiedErrorId : NotACLSComplaintProperty,Microsoft.PowerShell.Commands.GetMemberCommand
Finally I have wrote the same method with python and zeep library and when I pass this dictionnary as param it work juste fine :
{
'login': 'log',
'password': 'pass',
'entite': 'personne',
'criteres': {
'critere': {
'name': 'matricule',
'value': '001002',
'operator': 'eq'
},
'pageNum': 1,
'pageSize': 100
},
'details': True,
'completePath': False
}
Finnaly the code thank you for any help :
$url = "http://localhost:8081/search/V1?WSDL"
$WS = New-WebServiceProxy -Uri $url -Namespace ns
$type = $WS.GetType().NameSpace
#Type of object
$typeSc = $type + '.searchCriteria'
$typeScParam = $type + '.param'
# create object
$sc = new-object $typeSc
$scParam = new-object $typeScParam
$scParam | gm
#all crits
$crits = #{}
#one crit
$crit = #{}
$crit["name"] = "matricule"
$crit["operator"] = "eq"
$crit["value"] = "001002"
$crits["critere"] = $crit
# trying to cast crits into sc_param but the first issue is not here
$scParam = $crits
$sc.pageNum = 1
$sc.pageSize = 100
$sc.critere = $scParam

django rest framework - return custom data for a model serializer field

I have the following model:
class ServerSimpleConfigSerializer(mixins.GetCSConfigMixin, serializers.ModelSerializer):
mp_autoteambalance = serializers.BooleanField(label='Auto Team Balance', default=True, required=False)
mp_friendlyfire = serializers.BooleanField(label='Friendly Fire', default=False, required=False)
mp_autokick = serializers.BooleanField(label='Auto team-killer banning and idle client kicking', default=True, required=False)
# hostname = serializers.CharField(label='Hostname', max_length=75, required=True)
rcon_password = serializers.CharField(label='RCON Password', max_length=75, required=True)
sv_password = serializers.CharField(label='Server Password', max_length=75, required=False)
mp_startmoney = serializers.IntegerField(label='Start Money', required=False, validators=[MinValueValidator(800), MaxValueValidator(16000)])
mp_roundtime = serializers.FloatField(label='Round Time', required=False)
mp_timelimit = serializers.IntegerField(label='Map Time Limit', required=False)
fpath = os.path.join(settings.ROOT_DIR, "cs16/tmp/server.json")
class Meta:
model = CS16Server
fields = ('name', 'game_config', 'mp_autoteambalance', 'mp_friendlyfire',
'mp_autokick', 'hostname', 'rcon_password', 'sv_password',
'mp_startmoney', 'mp_roundtime', 'mp_timelimit')
read_only_fields = ('name', 'game_config',)
The model has the following fields:
name, game_config (big text) and hostname
How can I return the above defined fields for the serializer, although they are not present on the model ?
I would like to set some custom values for each field & return them as a JSON.
Is that possible ?
Actually the values for the above defined fields are found in "game_config" field.
I would like to parse those values & return them & I would not want to put them as separate fields in the model.
Parse game_config, obtain a pair of: (field0, val0) ... (fieldN, valN) and in the serializer,
set those values for the serializer fields.
For now I only get the following response:
{
"name": "Chronos",
"game_config": "hostname \"A New Gameservers.com Server is Born\"\nrcon_password \"\"\nsv_password \"1410271\"\nsv_contact email#domain.com\nsv_region 255\nsv_filterban 1\nsv_logbans 0\nsv_unlag 1\nmp_startmoney 800\nmp_chattime 30\nmp_footsteps 1\nsv_footsteps 1\nmp_logdetail 0\nmp_logmessages 0\nmp_timelimit 30\nmp_autokick 1\nmp_autoteambalance 1\nmp_flashlight 0\nmp_forcerespawn 0\nmp_forcechasecam 0\nmp_freezetime 0\nmp_friendlyfire 0\nmp_hostagepenalty 0\nmp_limitteams 0\nmp_roundtime 5\nmp_tkpunish 1\nsv_voiceenable 1\nsv_voicecodec voice_speex\nsv_voicequality 3\nsv_alltalk 0\nsv_restartround 1\nsv_maxspeed 320\nsv_proxies 1\nallow_spectators 1\nsv_allowupload 1\npausable 0\ndecalfrequency 40\nmp_falldamage 0\nsv_cheats 0\nsv_lan 0\nsv_maxrate 20000\nsv_minrate 4000\nexec listip.cfg",
"mp_autoteambalance": true,
"mp_friendlyfire": false,
"mp_autokick": true,
"hostname": "none"
}

moodle_database::insert_record_raw() no fields found

I'm trying to extract some data from an URL and store it into a table I created in Moodle, and it shows the error in Title. My goal is to extract all the values inside the attribute "nome" on cursos>curso and put them on my table ecoclipaluno.
Example Link. parameters of build URL, when changed, can give more values to store. Or less.
https://clip.unl.pt/sprs?lg=pt&year=2013&uo=97747&srv=rsu&p=1&tp=s&md=3&rs=8145&it=5&it=1030123459
function buildURL($year, $period, $typeperiod,$course)
{
return 'https://clip.unl.pt/sprs?lg=pt&year='.$year.'&uo=97747&srv=rsu&p='.$period.'&tp='.$typeperiod.'&md=3&rs='.$course.'&it=5&it=1030123459';
}
function doRequest_with_FileGetContents($url)
{
return file_get_contents($url);
}
function processXMLforCourse($xmlContent){
$xmlObj= new SimpleXMLElement($xmlContent);
$result=array();
foreach($xmlObj->unidade_curricular->cursos->curso as $curso){
$result[]= $curso->attributes()->nome;
}
return $result;
}
$context=get_context_instance(CONTEXT_COURSE,$courseid);
//$shortname=$course->shortname;
$idnumber=$course->idnumber;
$timecreated=$course->startdate;
$typeperiod='s';
if(date("m",$timecreated) >07 && date("m",$timecreated) <13){
$period='1';
$url=buildURL(date("Y",strtotime('+1 year',$timecreated)),$period,$typeperiod,$idnumber); // 1st semester
}
else{
$period='2';
$url=buildURL(date("Y",$timecreated),$period,$typeperiod,$idnumber); // 2nd semester
}
$content_b=doRequest_with_FileGetContents($url);
$dataClipCourse= processXMLforCourse($content_b);
$DB->insert_record('ecoclipaluno',$dataClipCourse);
From the Moodle API of data manipulation, the method insert_record has 4 parameters, the last 2 being optional, but none of them specifies the field. I wanted to insert $dataClipCourse to the field coursename. How can I pull that off?
array(8) { [0]=> object(SimpleXMLElement)#37 (1) { [0]=> string(54) "Licenciatura em Engenharia Informática (Tronco comum)" } 1=> object(SimpleXMLElement)#36 (1) { [0]=> string(38) "Mestrado em Matemática e Aplicações" } 2=> object(SimpleXMLElement)#44 (1) { [0]=> string(92) "Mestrado em Matemática e Aplicações, Especialização em Álgebra, Lógica e Computação" } 3=> object(SimpleXMLElement)#45 (1) { [0]=> string(82) "Mestrado em Matemática e Aplicações, Especialização em Matemática Financeira" } [4]=> object(SimpleXMLElement)#46 (1) { [0]=> string(104) "Mestrado em Matemática e Aplicações, Especialização em Análise Numérica e Equações Diferenciais" } [5]=> object(SimpleXMLElement)#47 (1) { [0]=> string(114) "Mestrado em Matemática e Aplicações - Especialização em Atuariado, Estatística e Investigação Operacional" } [6]=> object(SimpleXMLElement)#48 (1) { [0]=> string(74) "Licenciatura em Engenharia Informática, Perfil de Ciências da Engenharia" } [7]=> object(SimpleXMLElement)#49 (1) { [0]=> string(72) "Licenciatura em Engenharia Informática, Perfil de Informática Aplicada" } }
Edit:
The second parameter for insert_record() needs be an object rather than an array and have the field names as properties. eg:
$result = new stdClass();
$result->codigo = xxx;
$result->qualificacao_atribuida = xxx;
http://docs.moodle.org/dev/Data_manipulation_API#Inserting_Records
EDIT: I just noticed the processXMLforCourse() function returns an array of names - so maybe something like this
$dataClipCourse= processXMLforCourse($content_b);
foreach ($dataClipCourse as $nome) {
$data = new stdClass();
$data->nome = $nome->__toString();
$DB->insert_record('ecoclipaluno', $data);
}
The error message means that, after removing all member variables in $dataClipCourse that didn't match a fieldname in the table 'mdl_ecoclipaluno', there was no data left to insert.
I suggest you call 'var_dump($dataClipCourse);' to see what data was being inserted, then compare this to the definition of the table 'mdl_ecoclipaluno' in your database.

tcpdf date error Message: Undefined offset: 2

i have a date (datepicker jquery) $fecha_constancia:
public function generarReporte(){
$data_b = array();
$container = $this->input->get_post('opc_report', TRUE);
$paciente = $this->input->get_post('paciente', TRUE);
$odontologo = $this->input->get_post('odontologo', TRUE);
$fecha_constancia = $this->input->get_post('fecha_constancia', TRUE);
$diagnostico = $this->input->get_post('diagnostico', TRUE);
$reposo= $this->input->get_post('reposo', TRUE);
$reposo = $reposo*7;
list($day,$mon,$year) = explode('/',$fecha_constancia);
$nueva_fecha = date('d/m/Y',mktime(0,0,0,$mon,$day+$reposo,$year));
$data_a = array(
'fecha_constancia' => $fecha_constancia,
'diagnostico' => $diagnostico,
'fecha_reposo' => $nueva_fecha,
'dias_reposo' => $reposo
but when I'm going to spend the time to the Make pdf throws me the following result:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 2
Filename: controllers/constancia.php
Line Number: 38
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
Filename: controllers/constancia.php
Line Number: 38
is that the problem is in the date but not how to fix it
Check that the value of $fecha_constancia is an actual date in the format of Day/Month/Year.
This is line 38, correct?:
list($day,$mon,$year) = explode('/',$fecha_constancia);
Based on the error message, there's no slashes in $fecha_constancia. It can't assign anything to $mon and $year because explode is returning an array with a single element.