I'm trying to set the screen brightness on a nexus 10 tablet, using qpython3.
The following simple code, running in qpython3, results in an error
from androidhelper import Android
droid = Android()
# This works:
R = droid.getScreenBrightness()
print("SCREEN BRIGHTNESS",R)
# This errors out
print("SET BRIGHTNESS")
droid.setScreenBrightness(60.)
results in the error
java.lang.NullPointerException: throw with null exception
This is simplistic, so what I am doing wrong?
Related
I'm porting metaplex auction-house to Flutter mobile.
When creating auction with instant sale price of 0.1 wrapped sol, I have encountered the following error at the stage of ValidateSafetyDepositBoxV2 instruction.
The error was "Supplied an invalid creator index to empty payment account" and there is only one point where this message can be printed is Rust's process_empty_payment_account().
The most weird thing is that process_empty_payment_account function is called only from EmptyPaymentAccount instruction and my program didn't call it.
any idea what's happening?
Actual error log:
I/flutter ( 2718): {accounts: null, err: {InstructionError: [0, {Custom: 63}]}, logs: [Program p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98 invoke [1], Program log: Instruction: Validate Safety Deposit Box V2, Program log: Supplied an invalid creator index to empty payment account, Program p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98 consumed 11849 of 200000 compute units, Program p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98 failed: custom program error: 0x3f], unitsConsumed: 0}
I found the reason why that error was given after deploying a new program with some logs to the rust program. It was that I passed the wrong value for the metadata's address as the 4th account.
pub fn process_validate_safety_deposit_box_v2<'a>(
program_id: &'a Pubkey,
accounts: &'a [AccountInfo<'a>],
safety_deposit_config: SafetyDepositConfig,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let safety_deposit_config_info = next_account_info(account_info_iter)?;
let auction_token_tracker_info = next_account_info(account_info_iter)?;
let mut auction_manager_info = next_account_info(account_info_iter)?;
*let metadata_info = next_account_info(account_info_iter)?;*
....
So, the program failed at Metadata::try_from_slice_checked and returns error of InvalidCreatorIndex at the following code.
impl Metadata {
pub fn from_account_info(a: &AccountInfo) -> Result<Metadata, ProgramError> {
let md: Metadata =
try_from_slice_checked(&a.data.borrow_mut(), Key::MetadataV1, MAX_METADATA_LEN)?;
Ok(md)
}
}
It's a pity that the code didn't give a more elaborate error.
I have a block of try-exception code and I want to test if the block works properly? I wonder if there is a way to test this block with a unit test using pylint? This is the snipent I have:
class data_type(Enum):
SESSIONS = 0
RUNS = 1
def find_filter(data_type)
try:
if data_type.name == 'SESSIONS':
return {}
elif data_type.name == 'RUNS':
#Filter out rerun jobs
filter = {
"filter":{
"attName":"is_rerun",
"operand":"IN",
"#c":".InFilter",
"values":["FALSE"]
}
}
return filter
except AttributeError as erro:
loghandler.critical('Error in creating count query: {}'.format(erro))
I want to test if the data_type is not a valid enum member, the exception catches it before the execution goes to if statement. For example if:
find_filter('')
is called I like to see that the except AttributeError as erro captures the error and the error is logged.
Is there a way to do that?
PS: I know with pytest.raises() I can test if a raised error is really raised? But as far as I understand pytest.raises() does not work for testing the exception block of a try-exception case.
Any suggestion please?
Thanks.
I want to do an error handling of PipelineModel.load(PATH) i.e want to check if path exists if it doesn't exist, I want to exit the code so was trying try except block but don't exactly know what the error I should be expecting, Below is the snippet for same
try:
pipelineModel = PipelineModel.load(PATH)
except InvalidInputException:
print('Path Does not exist')
sys.exit(0)
Below is the error message
NameError: name 'InvalidInputException' is not defined
try:
pipelineModel = PipelineModel.load(S3LOC)
except Exception as e:
print('Exception Message ',e.args)
print('Model is not deployed')
sys.exit(0)
This snippet worked for me
sorry,I am a beginner and my English is very bad
i have a trouble in Flutter.
i reference https://pub.dartlang.org/packages/flutter_blue
I want to use flutter to communicate with the ear thermometer device.
when i reopen bluetooth and it can work,but I reopen app and excute second it show error.
i guess bluetooth gatt cahce is causing a error.
how can i solve it?
my code
deviceConnection = flutterBlue.scan(timeout: const Duration(seconds: 5),).listen((scanResult) async {
device = scanResult.device;
deviceConnection2 = await flutterBlue.connect(device, timeout: const Duration(seconds: 10),).listen(null);//this line error is error 1
deviceStateSubscription = device.onStateChanged().listen((s) async {
await device.discoverServices().then((s) async {//this is error 2
.........
}
}
}
it show these error
error 1
Dart Error: Unhandled exception:
PlatformException(already_connected, connection with device already exists, null)
error 2
Dart Error: Unhandled exception:
PlatformException(get_services_error, no instance of BluetoothGatt, have you connected first?, null)
Error 1
Dart Error: Unhandled exception: PlatformException(already_connected, connection with device already exists, null)
Since the app detected that a bluetooth device is already connected, one workaround is check for any connected device disconnect it. You can create a function that does this like the one in this GitHub thread:
What you can do here is that you check for any connected devices and
then disconnect them. I have written a function that does just that,
here it is:
checkConnectedDevices() async{
connectedDevices = await flutterBlue.connectedDevices.whenComplete((){
print(connectedDevices);
for(int i = 0; i < connectedDevices.length; i++){
connectedDevices[i].disconnect();
}
});
}
Error 2
Dart Error: Unhandled exception: PlatformException(get_services_error, no instance of BluetoothGatt, have you connected first?, null)
Since there is an error connecting to the device, you will not be able to call the discoverServices(). Because you need to be connected to a device before you can call this function. Check the following GitHub discussions related to this error:
connected ' discoverServices ' is't get #426
discoverServices is broken #535
Im trying to connect to wireless network from my uwp application (windows iot core os)
I can scan and list all wireless networks around me without any problem.
When i try to connect without credential connection fails as expected and program continues.
My problem is when i try to connect to a network with credentials my app closes and i cannot catch it even with using try catch.App goes from screen ( rasberry pi 3 ) and debug session is lost.Instead it should return me connection failed invalid credentials.
I'm also testing Microsoft samples for connecting wireless and i observed this behave happens in Microsoft sample when you try to connect to a network that you already connected it crashes without any exception
https://github.com/ms-iot/samples/tree/develop/WiFiConnector/CS
To Summurize; With following code if call firstAdapter.ConnectAsync() without credentials its normal but if call it with credentials program goes off from screen even without exception.
Note: i call await WiFiAdapter.RequestAccessAsync(); before i start.
my code as following
var adapterResult = await WiFiAdapter.FindAllAdaptersAsync();
if (adapterResult.Count >= 1)
{
WiFiAdapter firstAdapter = adapterResult[0];
await firstAdapter.ScanAsync();
var network = firstAdapter.NetworkReport.AvailableNetworks.FirstOrDefault();
PasswordCredential credential = new PasswordCredential();
credential.Password = "zp1PDQPdYFpCU";
try
{
WiFiConnectionResult result;
if (network.SecuritySettings.NetworkAuthenticationType == Windows.Networking.Connectivity.NetworkAuthenticationType.Open80211 &&
network.SecuritySettings.NetworkEncryptionType == NetworkEncryptionType.None)
{
result = await firstAdapter.ConnectAsync(network, WiFiReconnectionKind.Automatic);
}
else
{
result = await firstAdapter.ConnectAsync(network, WiFiReconnectionKind.Automatic, credential);
}
}
catch (Exception)
{
throw;
}