Getting Windows Version - operating-system

I am using Windows 10 (64 bit) Build 17763. I am writing a program where i need to check for windows version. I know there are different ways of doing this, but the problem is, each method brings out different result, and i am kindof confused why it should be so.
VB.Net
Console.WriteLine(Environment.OSVersion.Version)
Outputs: 6.2.9200 (Major: 6, Minor: 2, Build: 9200)
Powershell
[System.Environment]::OSVersion.Version
Outputs: Outputs: 10.0.17763 (Major: 10, Minor: 0, Build: 17763)
Java
System.out.println(System.getProperty("os.version"));
Outputs: 6.3 (which i guess Major is 6 while minor is 3)
Now, as you can see, all results are not the same. I need to know why, and which result to work with. Thanks

Related

Program and Run PIC18 with pickit4 on linux

I am on linux ubuntu and target is a PIC18F47J53.
I basically want to program the chip and then let it run, using command lines and using pickit4.
using ipecmd (from mplab x ide v5.45), this is my command:
/opt/microchip/mplabx/v5.45/sys/java/zulu8.40.0.25-ca-fx-jre8.0.222-linux_x64/bin/java -jar /opt/microchip/mplabx/v5.45/mplab_platform/mplab_ipe/ipecmd.jar -TPPK4 /P18F47J53 -M -F"/path_to_myfile.hex" -W
This is my output
DFP Version Used : PIC18F-J_DFP,1.4.41,Microchip
*****************************************************
Connecting to MPLAB PICkit 4...
Currently loaded versions:
Application version............00.06.66
Boot version...................01.00.00
Script version.................00.04.17
Script build number............db473af2f4
Tool pack version .............1.6.961
PICkit 4 is supplying power to the target (3.25 volts).
Target device PIC18F47J53 found.
Device Revision Id = 0x1
*****************************************************
Calculating memory ranges for operation...
Erasing...
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x3ff
program memory: start address = 0x1fc00, end address = 0x1fff7
configuration memory
Programming/Verify complete
Program Report
30-Jan-2021, 12:54:41
Device Type:PIC18F47J53
Program Succeeded.
Operation Succeeded
All good, and takes about 12 seconds, however, after that the pickit4 turns off the power target, and the pickit LED is BLUE (I guess state "ready")
The main question is how can I let the pickit4 powering the boards? any specific parameter? (I cannot find on the readme.html)
If I use MPLAB X IPE GUI to program, the programming is much quicker (3 or 4 seconds), the pickit LED is YELLOW and the target is left powered on. (I selected "release from reset")
I have tried to get the log out with as many details as possible, but I cannot see the commands sent to the pickit4.
Any idea? thanks
I realize that it's been a while since you asked, but i put the answer here for anyone who needs it. Add -OL to your command line options.

autoKey gtk 0.95.10 Icon get red an autoKey freezing

autoKey often stops working if i press my script shortcut F12
about every 70%. And about every 50% of them the icon gets red and autoKey is freezing. CPU load grows a little bit.
Its difficult to say what may the reason it.
The script (gist is a bit large. About 500 lines and offered on github.
I debug by sending while i recording my desktop to video file (youtub LKl4Ufhh3P8 ).
it open via wine a menu (autoHotKey script called lintalist) and catches the changed clipboard and writes it out.
When I restart the autoKey script it runs a couple of times (maybe three or five times). I inserted 100 milliseconds as a pause at various points. Since then, I don't have to restart the operating system, only kill the script when it freezes.
any idea what to try?
for debugging i use such little helpers:
import subprocess
doPopupNotify_howItWorks_counter = 0
doPopupNotify_howItWorks_firstNr = 15
doPopupNotify_howItWorks = True
def popupNotify(text):
subprocess.Popen(['notify-send', text]) # will be showed right top
def popupNotify_howItWorks(text):
global doPopupNotify_howItWorks, doPopupNotify_howItWorks_counter
if not doPopupNotify_howItWorks:
return
doPopupNotify_howItWorks_counter = doPopupNotify_howItWorks_counter + 1
if doPopupNotify_howItWorks_counter < doPopupNotify_howItWorks_firstNr:
return
subprocess.Popen(['notify-send', str(doPopupNotify_howItWorks_counter) + ") " + text]) # will be showed right top
time.sleep(.2)
System
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.4.0-52-generic
OS Type: 64-bit
autoKey gtk 0.95.10
These problems have not disappeared for a few days as a result of the following changes:
The solution described above uses the clipboard and keyboard together with Linux and Windows (Wine) conveyed via two scripting languages.
Apps:
clipboard ⇄ AutKey ⇄ AutoHotKey ⇄ Lintalist
operating systems:
clipboard ⇄ Kubuntu ⇄ WineHQ 1
Errors are more common in non-closed systems. Therefore, for example, such errors are typical (still open problem at 2020:11:12 in autokey):
"Hotkeys get lost when triggered frequently"
change from autokey-gtk to autokey-qt for systems using a Qt-based desktop environment such as KDE Plasma, Lumina, etc. For that there are different possibilities (github: install using pip3). I've used i used:
sudo apt-get remove --auto-remove autokey-gtk
sudo apt -y install autokey-qt
changed in AHK-Souce
ClipboardFirst := RTrim(LTrim(Clipboard, " `n`t:")," `n`t")
to
ClipboardFirst := RTrim(LTrim(Clipboard, " `n`t`r:")," `n`t`r")
The autokey icon still sometimes turns red, but the CPU load does not grow much and the system no longer freezes.
1: Wine is a free implementation of Windows on Linux.
Kubuntu Version 20.04
AutoKey Version 0.95.10
Python Version 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
wine-5.0.1

Assistance with Script To Automate Upgrades with PowerShell

I'm curious if someone can point me in the right direction here. I support a program that has several possible versions. Some of my customers are always on the latest version, while others seem to only upgrade once every few years. When the software is upgraded, you have to install every subsequent version until you get to the desired new version. So if we have versions 1, 2, 3, 4... all the way to version 10, and someone is upgrading from version 3 to version 9, we'd have to install 4, 5, 6, 7, 8, and then 9. Currently we have to manually run each individual version, so I'm looking at creating a script that will silently install each version and stop at the appropriate spot.
Currently, the only way I know to do this is to write a statement for every single possible combination for the original version and potential version. For example:
If starting version is 3 and ending version is 4
install 4
if starting version is 3 and ending version is 5
install 4
install 5
if starting version is 3 and ending version is 6
install 4
install 5
install 6
(and yes, I'm aware that's not proper powershell code, but I'm hoping you can get the jist of what I'm saying there).
So before I spend way too much time writing figuring out every single possible combination (we have upwards of 40 possible installs), does anyone have a suggestion where I can specify the order that the install files have to be run, then prompt for a starting and stopping point so it will only run between those variables? So for example, if a customer is on version 2 and wants to upgrade to version 8, it would just know to start with installing 3 and install every subsequent install until version 8?
Hoping this makes sense and any assistance would be great!
Given your problem statement and assuming you have enough knowledge to run the installs:
$softwareVersion = Get-Version # I assume you have a way to determine this
:installLoop do {
switch ([version]$softwareVersion) {
[version]'1.0' {
Install-V2
}
<# .. #>
default {
# no version?
break installLoop
}
}
$softwareVersion = Get-Version
} until ([version]$softwareVersion -ge [version]'10.0')
This is just a rough draft. In your case, I would utilize the Switch statement inside a Do loop
$BaseVersion = Get-Version #however you are checking... maybe a function you build
$TargetVersion = 10
Do
{
Switch ($BaseVersion)
{
1
{
Write-Host "Starting upgrade to Version 2"
Install-Version2
}
2
{
Write-Host "Starting upgrade to Version 3"
Install-Version3
}
default
{
Write-Host "No Version Detected"
break
}
}
Start-Sleep -Seconds 60 #Wait 1 min for install to complete before checking again
$Global:Baseversion = Get-Version
}Until($BaseVersion -lt $TargetVersion)

Nunit-console runner not running any tests

So I am trying to run a powershell script that is triggered by TeamCity to run specific unit tests based on the names of the files that were changed on each github commit.
Here is how I am running it from the command line:
C:\MyFolder\bin\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll" --test="MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest"
But I keep getting this, it runs it just never runs any tests:
NUnit Console Runner 3.4.1
Copyright (C) 2016 Charlie Poole
Runtime Environment
OS Version: Microsoft Windows NT 10.0.14393.0
CLR Version: 4.0.30319.42000
Test Files
MyFolder\Bin\UnitTesting.dll
Test Filters
Test: MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest
Run Settings
WorkDirectory: C:\Users\Me
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.0
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 2
Test Run Summary
Overall result: Passed
Test Count: 0, Passed: 0, Failed: 0, Inconclusive: 0, Skipped: 0
Start time: 2016-10-17 20:28:43Z
End time: 2016-10-17 20:28:43Z
Duration: 0.303 seconds
Results (nunit3) saved as TestResult.xml
Now when I run it without the --test command like this:
C:\MyFolder\bin\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll"
It runs every unit-test that we have, but I don't want to run them all, I want to run specific quick ones, and only run the large ones when we go to staging/production servers so our developers don't have to wait 15 to 20 minutes every time they commit something.
Some additional info:
-My namespace that I am using for this is
MyFolder.QuickTests.DaoTests.ProductDaoTests
The Class I am calling is:
ProductBasicTest
Some of the names like the folder directories were changed because they are %teamcity% placeholders for file directories.
What am I doing wrong to not be able to run specific tests?
For some reason my nunit-console is not recognizing the /run command or /fixture or --test=.
EDIT:
I upgraded to 3.5.0 and am still getting the same issues, I am not able to use --test.
C:\MyFolder\bin\NUnit.ConsoleRunner.3.5.0\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll" --test="MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest"
That is the new location, and getting the same issue.
When I do --where for MyFolder it crashes Powershell but doesn't actually run anything.
When I do --explore it does the same as --where for MyFolder and does nothing for MyFolder.QuickTests .
EDIT EDIT:
Thanks to Rob I found the docs here and looked at the --where function with --where "name=ProductBasicTest" which will run all the files in that Test-Suite!
So thanks to Rob one of the issues that I was running into, is it was not recognizing my namespace correctly with QuickTests. So whenever I ran the function it was not running correctly.
To fix this you can go to the Test xml file output and see what names it was running tests under.
To run these individually you can run it by the name with the command:
"nunit3-console.exe C:\PathToDll.dll --where "name = NameOfTest"

Pyinstaller --onefile warning pyconfig.h when importing scipy or scipy.signal

This is very simple to recreate.
If my script foo.py is:
import scipy
Then run:
python pyinstaller.py --onefile foo.py
When I launch foo.exe I get:
WARNING: file already exists but should not: C:\Users\username\AppData\Local\Temp\_MEI86402\Include\pyconfig.h
I've tested a few versions but the latest I've confirmed is 2.1dev-e958e02 running on Win7, Python 2.7.5 (32 bit), Scipy version 0.12.0
I've submitted a ticket with the Pyinstaller folks but haven't heard anything yet. Any clues how to debug this further?
You can hack the spec file to remove the second instance by adding these lines after a=Analysis:
for d in a.datas:
if 'pyconfig' in d[0]:
a.datas.remove(d)
break
The answer by wtobia# worked for me. See https://github.com/pyinstaller/pyinstaller/issues/783
Go to C:\Python27\Lib\site-packages\PyInstaller\build.py
Find the def append(self, tpl): function.
Change if tpl[2] == "BINARY": to if tpl[2] in ["BINARY", "DATA"]:
Expanding upon Ilya's solution, I think this is a little bit more robust solution to modifying the spec file (again place after the a=Analysis... statement).
a.datas = list({tuple(map(str.upper, t)) for t in a.datas})
I only tested this on a small test program (one with a single import and print statement), but it seems to work. a.datas is a list of tuples of strings which contain the pyconfig.h paths. I convert them all to lowercase and then dedup. I actually found that converting all of them all to lowercase was sufficient to get it to work, which suggests to me that pyinstaller does case-sensitive deduping when it should be case-insensitive on Windows. However, I did the deduping myself for good measure.
I realized that the problem is that Windows is case-insensitive and these 2 statements are source directories are "duplicates:
include\pyconfig.h
Include\pyconfig.h
My solution is to manually tweak the .spec file with after the a=Analysis() call:
import platform
if platform.system().find("Windows")>= 0:
a.datas = [i for i in a.datas if i[0].find('Include') < 0]
This worked in my 2 tests.
A more flexible solution would be to check ALL items for case-insensitive collisions.
I ran the archive_viewer.py utility (from PyInstaller) on one of my own --onefile executables that has the same error and found that pyconfig.h is included twice:
(31374007, 6521, 21529, 1, 'x', 'include\\pyconfig.h'),
(31380528, 6521, 21529, 1, 'x', 'Include\\pyconfig.h'),
(31387049, 984, 2102, 1, 'x', 'pytz\\zoneinfo\\CET'),
Sadly though, I don't know how to fix it.
PyInstaller Manual link:
http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html#archiveviewer