Categories
Mastering Development

DCG in Prolog What’s wrong with my program?

I want to Eliminate left recursion and incorporate precedence rules for expressions in the following grammar: problem digit –> [0]. digit –> [1]. digit –> [2]. digit –> [3]. digit –> [4]. digit –> [5]. digit –> [6]. digit –> [7]. digit –> [8]. digit –> [9]. identifier –> [x];[y];[z];[u];[v]. program –> block. command –> […]

Categories
Mastering Development

why isn’t CreateProcessW() performing the Command provided?

To present the minimal reproducible code I wrote a code to delete a file from a given location using CreateProcessW(). The file does not get deleted. Some help would be really useful in knowing why this isn’t working. dprintf((“Error %d”, GetLastError())); STARTUPINFO si = { sizeof(STARTUPINFO), 0 }; si.cb = sizeof(si); PROCESS_INFORMATION pi = { […]

Categories
Mastering Development

Is there any way to count how much time has passed in Python without delaying the program?

I’m sorry if this is a dup but I couldn’t find it online. I m writing a program that executes a couple of commands and then analyzes their outputs (In a Linux shell by the way. I’m running the commands with subprocess.run([‘Some’, ‘command’], stdout = subprocess.PIPE) The problem is that some of these commands run […]

Categories
Development

Restart Docker container during build process

I need to restart the Docker container during the build process due dotnetfx. Dockerfile: FROM mcr.microsoft.com/windows/servercore:ltsc2019 SHELL [“powershell”, “-Command”, “$ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’;”] # Install Chocolatey RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’)) # Universal Windows Platform build tools workload for Visual Studio 2019 Build Tools […]

Categories
Development

SSH subprocess command output(stdout) merging with error(stderr)

when sshing first time, when reading stdout, nothing returns. but when reading stderr – returns the warning merged with output of the command . How do i Separate the two when reading.? result: error: Warning: Permanently added the ECDSA host key for IP address x.x.x.x to the list of known hosts. 0+1 records in 0+1 […]

Categories
Development System & Network

issues with launching jenkins agents on kubernetes using kubernetes plugin with jenkins

I am getting the following error trying to integrate jenkins server to kubernetes cluster so that jenkins agents are spun on on the kubernetes cluster to run jobs 2020-02-06 17:21:26.875+0000 [id=961] WARNING o.c.j.p.k.KubernetesLauncher#launch: Error in provisioning; agent=KubernetesSlave name: kubernetes-1f2n5, template=PodTemplate{inheritFrom=”, name=’kubernetes’, namespace=”, label=’kubernetes’, serviceAccount=’default’, nodeSelector=”, nodeUsageMode=EXCLUSIVE, workspaceVolume=EmptyDirWorkspaceVolume [memory=false], volumes=[HostPathVolume [mountPath=/var/run/docker.sock, hostPath=/var/run/docker.sock]], containers=[ContainerTemplate{name=’jnlp’, image=’joao29a/jnlp-slave-alpine-docker’, workingDir=’/home/jenkins/’, command=”, […]

Categories
Development

In Go, how do I assign additional ExraFiles using Pipes to have more than one output stream?

I have a command to which I send data through Stdin and expect 28 output streams (including Stdout). So I wanted to use the cmd.ExtraFiles field with an os.Pipe for each of the os.ExtraFiles. I wrote the following: backgroundContext, cancelCommand := context.WithCancel(context.Background()) cmd := exec.CommandContext(backgroundContext, “command”, args…) cmd.ExtraFiles = make([]*io.File, 27, 0) var outputPipe io.ReadCloser […]

Categories
Development

PyQt-thread. Get dynamically output

I use PyQt-thread for parallel conversion of mp3 files to aac via ffmpeg. Here is my code: class SubprocessThread(QThread): signal = pyqtSignal(‘PyQt_PyObject’) def __init__(self, command, args): QThread.__init__(self) self.command = command self.args = args def __del__(self): self.wait() def run(self): output = subprocess.check_output(‘{0} {1}’.format(self.command, self.args), shell=True).split() self.signal.emit(output) And here is example of usage: threads = [] for […]

Categories
Development

Treating signals correctly inside system()

I have been reading “The Linux Programming Interface”. Chapter 27, Program execution. I understand that the author demonstrates how we could implement the system call using exec and fork. However, the challenging part is handling signals. In particular I am confused with the following text The first signal to consider is SIGCHLD. Suppose that the […]

Categories
Development

Subprocess run, check_output, Popen returns empty string when I run the script from a batch file

I have a batch file which is running a python script and in the python script, I have a subprocess function which is being ran. I have tried subprocess.check_output, subprocess.run, subprocess.Popen, all of them returns me an empty string only when running it using a batch file. If I run it manually or using an […]