py2neo.packages.httpstream.http.SocketError: Connection refused - neo4j

When I try to run the python file “joern-plot-ast” and output some result in the database Neo4j, I got the error "py2neo.packages.httpstream.http.SocketError: Connection refused".
use neo4j version: 2.1.8.
python version:2.7.
py2neo:2.0
String cmd1 = "echo \'queryNodeIndex(\"type:Function\").id\' | " +
"python /home/sun/下载/joern-tools/build/scripts-2.7/joern-lookup -g | " +
"python /home/sun/下载/joern-tools/build/scripts-2.7/joern-plot-ast | " +
"python /home/sun/下载/joern-tools/build/scripts-2.7/joern-astlabel | " +
"python /home/sun/下载/joern-tools/build/scripts-2.7/joern-ast2features >" + outputfilename;
Process joernscripts = dbTime.exec((new String[]{"/bin/sh","-c", cmd1}));
joernscripts.waitFor(); BufferedReader br5 = new BufferedReader(new InputStreamReader(joernscripts.getInputStream()));
while(br5.ready())
System.out.println(br5.readLine());
Actual results: see the pic.

Related

Error in Upload watchdog: [System.Object[]] no method with the name "op_Addition"

I need help with a script that monitors the upload.
The script is intended to prevent crashes of OBS, where OBS simply stops sending data. I have already run this script on several streaming PCs - without problems. But on a new streaming PC it just won't run.
Here is the script for now:
$threshold = 6000
$timer = new-timespan -Seconds 10
$wmi = 0
$count = 0
$clock = [diagnostics.stopwatch]::StartNew()
while ($clock.elapsed -lt $timer){
$wmi += (Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface | Select-Object BytesSentPerSec).BytesSentPerSec
$count++
}
$kbytes = ($wmi/$count) / 1kb * 8 #to kbit/s
if($kbytes -le $threshold)
{
Write-Output $kbytes
Write-Host "Neustart"
taskkill /f /im obs64.exe
timeout /t 5
Start-Process -FilePath "obs64.exe" -WorkingDirectory "C:\Program Files\obs-studio\bin\64bit\" --startstreaming
}
else
{
Write-Output $kbytes
Write-Host "Alles OK"
}
As an error I get this:
Code:
Error when calling the method. [System.Object[]] no method with the name "op_Addition".
In C:\Users\stream1\Desktop\watchdog.ps1:8 Zeichen:5
+ $wmi += (Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_Netwo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
The program was written for me by someone. Unfortunately, I myself have no experience in programming in Powershell. I would be very grateful for any help.
I hope someone can help me.
Thanks a lot
Greeting
Thomas
"$wmi = 0" --> "$wmi = #()"
Error:
Error calling the method because [System.Object[]] does not contain a method named "op_Division".
In C:\Users\stream1\Desktop\watchdog.ps1:12 character:1
+ $kbytes = ($wmi/$count) / 1kb * 8 #to kbit/s
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Division:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

appium-java Unknown HttpClient factory apache when initializing driver

I'm trying to migrate from appium-java client 7.0 to 8.3 - After updating to 8.3 version I get an error when initializing appium driver (for iOS)
java.lang.IllegalArgumentException: Unknown HttpClient factory apache
at org.openqa.selenium.remote.http.HttpClient$Factory.create(HttpClient.java:57)
at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:73)
at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:108)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:106)
Command to start appium server is build smth like this
command = nodePath + " " + appiumMainJS + " ";
command = command + " -a " + hostName + " -p " + availablePort + " ";
command = command + " -cp " + (availablePort + 1000) + " -bp " + (availablePort + 2000);
command = command + " --chromedriver-port " + (availablePort + 3000);
command = command + " " + appiumArgs;
Capabilities
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, OS_VERIOSN);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability("appium:keychainPath", KEYCHAIN_PATH);
capabilities.setCapability("appium:keychainPassword", KEYCHAIN_PASSWORD);
capabilities.setCapability("appium:xcodeOrgId", XCODE_ORG_ID);
capabilities.setCapability("appium:xcodeSigningId", XCODE_SIGNING_ID);
capabilities.setCapability("appium:deviceName", DEVICE_NAME);
capabilities.setCapability("appium:showXcodeLog", true);
capabilities.setCapability("appium:noReset", false);
capabilities.setCapability("appium:simpleIsVisibleCheck", false);
capabilities.setCapability(MobileCapabilityType.UDID, DEVICE_ID);
capabilities.setCapability("appium:newCommandTimeout", "2000000");
capabilities.setCapability("appium:launchTimeout", "120000");
capabilities.setCapability("appium:shouldUseSingletonTestManager", false);
capabilities.setCapability("appium:wdaConnectionTimeout", 15*60*1000);
capabilities.setCapability("appium:sendKeyStrategy", "setValue");
capabilities.setCapability("appium:session-override", true);
capabilities.setCapability("appium:webkitResponseTimeout", 20000);
capabilities.setCapability("appium:useJSONSource", true);
capabilities.setCapability("appium:sendKeyStrategy", "grouped");
capabilities.setCapability("appium:commandTimeouts", "1000000");
capabilities.setCapability("appium:webDriverAgentUrl", customWdaUrl);
capabilities.setCapability("appium:webDriverAgentUrl", WDA_SERVER_URL);
capabilities.setCapability(IOSMobileCapabilityType.WDA_LOCAL_PORT, wdaPort);
Driver is initialized like this
IOSDriver iosDriver = new IOSDriver(url, capabilities);
What could be the issue here?

file not found,jenkins pipline

I am getting file not found error on my Jenkins job.
if (component_meta ==null)
echo "path = " + component_meta
else if (component_meta.tf_version !=null){
echo "path = " + component_meta
echo "version = " + component_meta.tf_version
dir ("base/" + component_meta.path){
sh 'rm -rf .terra*'
sh "terragrunt plan --terragrunt-tfpath /usr/local/bin/tf/versions/" + component_meta.tf_version + "/terraform" + " -detailed-exitcode"
}
}
error I beleive is in the system of below command
sh "terragrunt plan --terragrunt-tfpath /usr/local/bin/tf/versions/" + component_meta.tf_version + "/terraform" + " -detailed-exitcode"

Code working in Powershell ISE 2.0 but not ISE 4.0

The following code open a random number generator, selects the button to run the generator, and returns a random number.
#Start-Process
$ie = New-Object -com InternetExplorer.Application
$ie.Navigate("https://www.random.org/widgets/integers/iframe.php?title=True+Random+Number+Generator&buttontxt=Generate&width=160&height=200&border=on&bgcolor=%23FFFFFF&txtcolor=%23777777&altbgcolor=%23CCCCFF&alttxtcolor=%23000000&defaultmin=1&defaultmax=100&fixed=off")
$ie.visible = $true
echo "Random.org opening"
while( $ie.busy){Start-Sleep 1}
sleep 10
echo "Random.org open"
$FindBtn = $ie.Document.getElementByID("true-random-integer-generator-button").click()
sleep 5
$result = $ie.Document.getElementByID("true-random-integer-generator-result").innerHTML
echo $result
This works fine for me in powershell 2.0, however, when I run in 4.0, iget the following errors:
You cannot call a method on a null-valued expression.
At line:13 char:1
+ $FindBtn = $ie.Document.getElementByID("true-random-integer-generator-button").c
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:15 char:1
+ $result = $ie.Document.getElementByID("true-random-integer-generator-result").in
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
What is the reason behind this? Is there a big formatting difference between powershell 4.0 and 2.0? 4.0 is on a different VM to 2.0, could that be having an affect?

Backup SSRS Encryption Keys Using Powershell

I have made the following script from google for backing up the SSRS Encryption keys:
cls
$pwd = "sa#123#123"
$SSRSClass = Get-Wmiobject -namespace "root\microsoft\sqlserver\reportserver\rs_BPSSRS\v10\admin" -class "MSReportServer_ConfigurationSetting"
$key = $SSRSClass.BackupEncryptionKey($pwd)
$stream = [System.IO.File]::Create("c:\\SSRS.snk", $key.KeyFile.Length)
$stream.Write($key.KeyFile, 0, $key.KeyFile.Length)
$stream.Close()
But I'm getting the following errors:
Method invocation failed because [System.Object[]] doesn't contain a method named 'BackupEn
cryptionKey'.
At line:5 char:38
+ $key = $SSRSClass.BackupEncryptionKey <<<< ($results)
+ CategoryInfo : InvalidOperation: (BackupEncryptionKey:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : MethodNotFound
Exception calling "Create" with "2" argument(s): "Positive number required.
Parameter name: bufferSize"
At line:6 char:35
+ $stream = [System.IO.File]::Create <<<< ("c:\\SSRS.snk", $key.KeyFile.Length)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
You cannot call a method on a null-valued expression.
At line:7 char:14
+ $stream.Write <<<< ($key.KeyFile, 0, $key.KeyFile.Length)
+ CategoryInfo : InvalidOperation: (Write:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:8 char:14
+ $stream.Close <<<< ()
+ CategoryInfo : InvalidOperation: (Close:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I'm using powershell v2. I tried finding about this but no luck. There are around 50+ SSRS servers in our environment and doing backup manually is tiresome. Hence, we came up with this automation. Kindly provide your comments.
Thanks
This piece of code should do the trick:
$ComputerName = "."
$KeyFolder = "C:\Temp"
$KeyPassword = "sa#123#123"
$TimeStamp = Get-Date -Format "-yyyyMMdd-HHmmss"
Get-WmiObject -Namespace "Root\Microsoft\SqlServer\ReportServer" -Class "__Namespace" -ComputerName $ComputerName |
Select-Object -ExpandProperty Name |
% {
$NameSpaceRS = $_
$InstanceName = $NameSpaceRS.SubString(3)
$KeyFileName = Join-Path -Path $KeyFolder -ChildPath ($InstanceName + $Timestamp + ".snk")
"Found Reporting Services in instance '$($InstanceName)' on $($ComputerName); will save key to '$($KeyFileName)' ..."
$SQLVersion = (Get-WmiObject -Namespace "Root\Microsoft\SqlServer\ReportServer\$($NameSpaceRS)" -Class "__Namespace" -ComputerName $ComputerName).Name
$SSRSClass = Get-WmiObject -Namespace "Root\Microsoft\SqlServer\ReportServer\$($NameSpaceRS)\$($SQLVersion)\Admin" -Query "SELECT * FROM MSReportServer_ConfigurationSetting WHERE InstanceName='$($InstanceName)'" -ComputerName $ComputerName
$Key = $SSRSClass.BackupEncryptionKey($KeyPassword)
If ($Key.HRESULT -ne 0) {
$Key.ExtendedErrors -join "`r`n" | Write-Error
} Else {
$Stream = [System.IO.File]::Create($KeyFileName, $Key.KeyFile.Length)
$Stream.Write($Key.KeyFile, 0, $Key.KeyFile.Length)
$Stream.Close()
}
}
The errors that you have mentioned are because your code is trying to fetch information from duplicate entries. Meaning, if you try the above code on the server where only one named instance of SSRS is running, then I suppose it will succeed. Just try this piece and give your comments.
CHEERS.

Resources