QPSQL driver not loaded (Qt6, Postgres-13) - qt

I try to repeat QPSQL driver not loaded Qt but it does not helped me. I used x64 Postgresql and my Qt application also x64
m_dataBase.addDatabase("QPSQL");
m_dataBase.setHostName(g_hostName);
m_dataBase.setPort(g_databasePort);
m_dataBase.setDatabaseName(g_databaseName);
m_dataBase.setUserName(g_userName);
m_dataBase.setPassword(g_password);
qInfo() << "drivers:" << m_dataBase.drivers();
if( !m_dataBase.isDriverAvailable("QPSQL")) {
qWarning() << "Driver QPSQL is not available";
} else {
qInfo() << "QPSQL is available";
}
if (m_dataBase.open()) {
qInfo() << "Data base open SUCCESSFUL";
return true;
} else {
qWarning() << "Data base does not open";
qInfo() << "Last ERROR:" << m_dataBase.lastError().driverText();
}
I enabled
qputenv("QT_DEBUG_PLUGINS", "1");
for editional debug logs.
I update PATH variable in cmd
SET PATH=D:\PostgresLib\lib;%PATH%
SET PATH=D:\PostgresLib\bin;%PATH%
and after what I see in output:
[06/05/2021 10:28:13.305] DBG line: QFactoryLoader::QFactoryLoader() looking at "C:/Qt/6.0.3/mingw81_64/plugins/sqldrivers/qsqlpsql.dll"
[06/05/2021 10:28:13.306] WAR line: Found metadata in lib C:/Qt/6.0.3/mingw81_64/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL"
]
},
"archreq": 0,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 393216
}
[06/05/2021 10:28:13.306] DBG line: Got keys from plugin meta data QList("QPSQL")
[06/05/2021 10:28:13.306] DBG line: QFactoryLoader::QFactoryLoader() checking directory path "D:/Projects/Build/sqldrivers" ...
[06/05/2021 10:28:13.309] DBG line: loaded library "C:/Qt/6.0.3/mingw81_64/plugins/sqldrivers/qsqlpsql.dll"
[06/05/2021 10:28:13.309] INF postgresdatabase.cpp virtual bool PostgresDataBase::init() line:24 drivers: QList("QSQLITE", "QODBC", "QPSQL")
[06/05/2021 10:28:13.309] INF postgresdatabase.cpp virtual bool PostgresDataBase::init() line:29 QPSQL is available
[06/05/2021 10:28:13.309] WAR postgresdatabase.cpp virtual bool PostgresDataBase::init() line:36 Data base does not open

The problem was in non initialized object QSqlDatabase m_dataBase;
fix:
instead of this string
m_dataBase.addDatabase("QPSQL");
I use
m_dataBase = QSqlDatabase::addDatabase("QPSQL");

Related

How to verify polygon smart contract using truffle?

I deployed a simple NFT smart contract on polygon mumbai testnet but when I am trying to verify it then It is showing an error. please guide me how to verify it...
This is the error which I am getting
PS C:\Users\Sumits\Desktop\truffle> truffle run verify MyNFT --network matic --debug
DEBUG logging is turned ON
Running truffle-plugin-verify v0.5.20
Retrieving network's chain ID
Verifying MyNFT
Reading artifact file at C:\Users\Sumits\Desktop\truffle\build\contracts\MyNFT.json
Failed to verify 1 contract(s): MyNFT
PS C:\Users\Sumits\Desktop\truffle>
This is my truffle-config.js
const HDWalletProvider = require('#truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
matic: {
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.maticvigil.com`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "^0.8.0",
}
},
plugins: ['truffle-plugin-verify'],
api_keys: {
polygonscan: 'BTWY55K812M*******WM9NAAQP1H3'
}
}
First deploy the contract:
truffle migrate --network matic --reset
I am not sure if you successfully deploy it to matic network, because your configuration does not seem to be correct:
matic: {
// make sure you set up provider correct
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.maticvigil.com/v1/YOURPROJECTID`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
Then verify.
truffle run verify ContractName --network matic
ContractName should be the name of the contract, not the name of the file
please make sure you are putting the polygonscan api key in lowercase

How to access file data from firebase storage without downloading

I have a URL for my file type .ies that is uploaded on firebase storage and I want to read the content inside the file but when I hit URL on the browser it only returns the information about the file, not the content
Example link: https://firebasestorage.googleapis.com/v0/b/westgatedash-d1341.appspot.com/o/documents%2FIES%2FCDL2-45W-M-120V_IESNA2002.IES
but when I use query params alt=media it downloads that I don't want.
Are there any query params to get the data of the file? or any way to achieve the goal ?
According to the documentation, each call is different and for different purposes:
Listing objects:
To list the objects in a bucket:
curl -X GET -H "Authorization: Bearer OAUTH2_TOKEN" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o"
Downloading objects:
curl -X GET \
-H "Authorization: Bearer OAUTH2_TOKEN" \
-o "SAVE_TO_LOCATION" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o/OBJECT_NAME?alt=media"
The difference when hitting the endpoint is, precisely, the alt=media param. What I understand is that you might want to stream the object? If so, you can achieve it through the client libraries. For instance:
To handle the file on a Cloud Function you can follow this guide you will find more detailed info. As a summary, to download a file:
// Download file from bucket.
const bucket = admin.storage().bucket(fileBucket);
const tempFilePath = path.join(os.tmpdir(), fileName);
const metadata = {
contentType: contentType,
};
await bucket.file(filePath).download({destination: tempFilePath});
console.log('Image downloaded locally to', tempFilePath);
This will save the image to a temporary folder since this is the recommended way to do it.
Use gcs.bucket.file(filePath).download to download a file to a temporary directory on your Cloud Functions instance. In this location, you can process the file as needed.
EDIT
According to Downloads Documentation:
You can send download requests to Cloud Storage in the following ways:
Simple download: Downloading objects to a destination.
Streaming download: Downloading data to a process.
Sliced object download: Downloading large objects.
In the Docs, following the GitHub Repo: For C++ it shows a stream downloading:
void ReadObject(google::cloud::storage::Client client,
std::vector<std::string> const& argv) {
//! [read object] [START storage_download_file]
namespace gcs = google::cloud::storage;
[](gcs::Client client, std::string const& bucket_name,
std::string const& object_name) {
gcs::ObjectReadStream stream = client.ReadObject(bucket_name, object_name);
int count = 0;
std::string line;
while (std::getline(stream, line, '\n')) {
++count;
}
std::cout << "The object has " << count << " lines\n";
}
//! [read object] [END storage_download_file]
(std::move(client), argv.at(0), argv.at(1));
}
But for NodeJs, for some reason, it doesn't. I was not able to find any example of that. On the other hand there are other questions in SatckOverflow with the same question, i.e: this:
const {Storage} = require('#google-cloud/storage');
const storage = new Storage();
const bucket = storage.bucket(bucket);
const remoteFile = bucket.file(file);
let buffer = '';
remoteFile.createReadStream()
.on('error', function(err) {console.log(err)})
.on('data', function(response) {
buffer += response
})
.on('end', function() {
//console.log(buffer);
res.send(buffer);
})

receive error "getTokens does not support retrieving tokens while signed" when try to retrieve data from AWS via API Gateway

issue:
console show "getTokens does not support retrieving tokens while signed-" error.
step:
1. run app with Android studio
2. log in AWS ( my app use amplify drop-in UI )
3. retrieve data from AWS via API Gateway --> result OK ( able to retrieve)
4. log out and log in again
5. retrieve data from AWS via API Gateway --> result NG ( show above error)
note:
my configuration file include: Cognito User pool and Identity pool. this is auto generate after keyin " amplify add auth" at CLI.
if i deleted Cognito Identity pool from configuration file, issue not happen.
May i know why ?
my configuration file:
{
"UserAgent": "aws-amplify-cli/0.1.0",
"Version": "1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "xxx",
"Region": "us-east-2"
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId": "us-east-2_xxx",
"AppClientId": "xxx",
"AppClientSecret": "xxx",
"Region": "us-east-2"
}
}
}
sign-in code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authentication);
AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {
#Override
public void onResult(UserStateDetails userStateDetails) {
switch (userStateDetails.getUserState()) {
case SIGNED_IN:
Intent i = new Intent(Authentication.this, AvailableFlavor.class);
break;
case SIGNED_OUT:
showSignIn();
break;
default:
AWSMobileClient.getInstance().signOut();
showSignIn();
break;
}
}
#Override
public void onError(Exception e) {
}
});
}
private void showSignIn() {
try {
AWSMobileClient.getInstance().showSignIn(this,
SignInUIOptions.builder().nextActivity(LoginSuccess.class)
.build());
} catch (Exception e) {
// Log.e(TAG, e.toString());
}
}
}
I guess the end of the error is "getTokens does not support retrieving tokens while signed-"...out?
I had a similar error, please check if your identity poolId is correct (even if you're not using a guest access or if you only want to use the user pool functionality) in app -> src -> res -> raw -> amplifyconfiguration.json & awsconfiguration.json. You can find your poolId in your AWS console -> cognito -> manage identity pools -> click on your pool -> click on Sample code.:

Chrome App - Cannot read property 'connect' of undefined

I'm working on a Raspberry pi 3, I have a webpage that sends text data to a Chrome App, and everything works fine up to here.
After that the Chrome App should send that data to the serial port and here appears the error:
Error in event handler for runtime.onMessageExternal: TypeError: Cannot read property 'connect' of undefined
The problem could be that this is not a Chrome App, it's an Extension and it can't use this API cause only Chrome Apps have access to the hardware, but I followed this guide to make my first Chrome App (https://developer.chrome.com/apps/first_app), so maybe there's something i didn't understand or a step that i missed.
Here's my code, thanks in advance for the help!
manifest.json
{
"name": "Send serial data",
"description": "App to send serial data.",
"version": "1.0",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "img-16.png", "128": "img-128.png" },
"externally_connectable" : {
"matches": ["*://localhost/*"]
}
}
background.js
var msg ;
function openSend(data) {
var onConnect ;
onConnect = function(connectionInfo) {
_this.connectionId = connectionInfo.connectionId;
}
chrome.serial.connect("/dev/ttyAMA0", {bitrate: 115200}, onConnect);
chrome.serial.send(connectionId, convertStringToArrayBuffer(data), function(sendInfo) {
if(sendInfo.error) $.modal('<div id="title">Unable to send data: ' + sendInfo.error + '</div>')
});
}
chrome.runtime.onMessageExternal.addListener((message, sender, sendResponse) => {
console.log(message.data);
msg = message.data ;
openSend(msg);
});
Solved, i just forgot to put this line of code in my manifest.json:
"permissions":["serial"],

Unable install own google chrome extension

i want to host my own extension on my asp.net server (it's free web server, so i don't have access to machine.config etc.).
But the point of my problem is here. I put the packaged extension to server and i want use something like this:
protected void Page_Load(object sender, EventArgs e)
{
string file = Request.QueryString["f"];
if (file != null)
{
Response.Write("");
if (file == "0")
{
Response.ContentType = "application/x-chrome-extension";
Response.AddHeader("Content-Disposition", "attachment;filename=RemotePlay_extension.crx");
Response.TransmitFile("~/Extensions/Update/RemotePlay_extension.crx");
}
else
{
Response.ContentType = "application/x-chrome-extension";
Response.AddHeader("Content-Disposition", "attachment;filename=RemotePlay_extension.crx");
Response.TransmitFile("~/Extensions/RemotePlay_extension.crx");
}
}
}
But every time I get this error:
Source of extension manifest:
{
"name": "Remote Play",
"description": "DJ interface to use RP.",
"version": "0.0.0.2",
"update_url": "../Extensions/RemoteChrome_Update.xml",
"permissions": ["tabs", "http://*/*"],
"background": { "scripts": ["background.js"] },
"content_scripts": [{"matches": ["http://*/*"],"js": ["inject.js"]}],
"page_action": {"default_icon": "playico.png", "default_popup": "popup.html"},
"manifest_version": 2
}
What i'm doing wrong? Where is that error?
You can not trigger installation through Page_Load function and headers
You should have a link tag <link rel="chrome-webstore-item"
href="https://chrome.google.com/webstore/detail/apdfllckaahabafndbhieahigkjlhalf">
You can trigger installation through chrome.webstore.install(url, successCallback, failureCallback)
For more information check documentation.

Resources