syntax errors in model checking with nuXmv - model-checking

Now there are two options for customer, phone call and sms to clinic to book an appointment with doctor. The phone call or sms need to deliver to phone attender or reception, then do the next.... Well as we know, the phone call and sms can successful deliver or fail deliver, the solution of fail deliver will continue to try again the same way of user select or another one.
Based on the above background, I write some codes for doing model checking behavior to implement it. I am quite new of the class, anyone can help to find the anything wrong with my codes.
MODULE call
VAR
option:{call,sms};
call:{successful,fail,again};
sms:{successful,fail,again};
phone_attender:{available,unavailable};
ASSIGN
init(option):=call|sms;
next(call):=case
call=successful:successful;
call=successful&phone_attender=available:{successful,available};
call=fail&phone_attender=fail:{fail,unavailable};
call=fail&phone_attender=fail:{again,unavailable};
call=again&phone_attender=successful:{again,available};
1:{successful,fail,again};
esac;
next(sms):=case
sms=successful&phone_attender:successful{successful};
sms=fail&phone_attender=fail:{fail,unavailable};
sms=fail&phone_attender=fail:{again,unavailable};
sms=again&phone_attender=successful:{again,available};
1:{successful,fail,again};
next(phone_attender):=case
phone_attender=available(call=successful|call=again)&(sms=successful|sms=again);
phone_attender=unavailable(call=fail|call=again)&(sms=fail|sms=again);
1:phone_attender;
esac;
It always remainder me syntax errors and run in the terminal with nuXmv.

Line 20:
file test.smv: line 20: at token "{": syntax error
The problem is given by the following condition:
sms=successful&phone_attender:successful{successful};
The value successful{successful} doesn't make any sense, choose between successful or {succesful}. Both are interpreted in the same way.
Line 26:
file test.smv: line 26: at token ":=": syntax error
You did not close the case construct of the previous assignment. Add esac; after the last condition.
Lines 28/29:
file test.smv: line 28: at token ";": syntax error
file test.smv: line 29: at token ";": syntax error
You did not provide the next value for phone_attender for the first two cases.
Note: I did not check the semantics of your model, since it is not even syntactically correct.

Related

open() throwing mypy issues which reading an image file

I have the following line of code which reads an image (which is fed into a POST request):
files = {"image": (image_path, open(image_path, "rb"))}
While trying to run this through mypy, it keeps throwing the following error:
Argument 1 to "open" has incompatible type "Optional[str]"; expected "Union[Union[str, bytes, PathLike[str], PathLike[bytes]], int]"
I've tried searching this, but I've not found a solution for similar problems.
Is there a different way to read filepaths in order to avoid these issues?
Not the correct answer but if you want to temporarily make it go away to move ahead:
# type: ignore
at the end of the erroring line should work.

Incomplete statement at end of file

After running below command :
sh cqlsh --request-timeout=3600 -f test.cql
I am getting below error :
Incomplete statement at end of file
Even when my first line is use sample; followed by 50 insert queries.
What could be the reasons for this error?
That error is returned if the statement at the end of the file either (a) has invalid syntax, or (b) not terminated correctly.
Sometimes the issue can occur several lines up from the last statement in the input file.
Check that the CQL statements have valid syntax. It might be necessary to do a process of elimination and split the file so there's only 10 statements in each so you can identify the offending statement. Cheers!

Opening .hoc files in neuron simulator + "not a mechanism" problem

I am trying to run a NEURON simulation via python. I got all the libraries in order and am able to run some simple simulations, but am experiencing some troubles with a more complicated code. If you have any idea how to help I will appreciate it very much
Problem number 1:
Neuron doesn't open part of a .hoc file even though it is compiled. I get the error:
NEURON: Can't open import3d/import3d_sec.hoc
in import3d.hoc near line 1
{xopen("import3d/import3d_sec.hoc")}
^
xopen("import3d/i...")
xopen("import3d.hoc")
execute1("{xopen("im...")
load_file("C:/Users/U...")
Problem number 2:
The simulator doesn't recognize a mechanism I am trying to use. here I am a bit lost and don't know to describe further, but this is the error message:
NEURON: Im is not a MECHANISM
in L5PCbiophys5b.hoc near line 26
insert Im
^
xopen("L5PCbiophy...")
execute1("{xopen("L5...")
load_file("C:/Users/U...")
Problem number 3:
Not recognizing as a template:
NEURON: Import3d_Neurolucida3 is not a template
in L5PCtemplate_2.hoc near line 26
nl = new Import3d_Neurolucida3()
^
xopen("L5PCtempla...")
execute1("{xopen("L5...")
load_file("C:/Users/U...")
You can try to use an absolute path
The name for insert should match with the SUFFIX statement in the file; also make sure that file was compiled in and that the dll is loaded (should be a message when you start nrniv)
Perhaps a result of the file xopen problem? If it is a template-containing file you should use load_file() instead of xopen()

How to overcome 'salt must be a byte string error'?

Good morning,
I'm trying to recover my Multibit HD seed words using decrypt_bitcoinj_seed.py I don't know if anyone has used decrypt_bitcoinj_seed.py or not but I'm getting an error after it runs another python script in its arsenal called common.py with an error:
raise TypeError('salt must be a byte string')
There are many opportunities for errors to be thrown is this python script, so if this one is overcome there could be others to follow. (Please see code at the bottom.) The code below shows the salt error.
C:\Python38\decrypt_bitcoinj_seed-master>py decrypt_bitcoinj_seed.py
Traceback (most recent call last):
File "decrypt_bitcoinj_seed.py", line 319, in <module>
wallet = load_wallet(wallet_file, get_password)
File "decrypt_bitcoinj_seed.py", line 132, in load_wallet
key = pylibscrypt.scrypt(password.encode('utf_16_be'), salt, olen=32)
File "C:\Python38\lib\site-packages\pylibscrypt\hashlibscrypt.py", line 49, in scrypt
check_args(password, salt, N, r, p, olen)
File "C:\Python38\lib\site-packages\pylibscrypt\common.py", line 49, in check_args
raise TypeError('salt must be a byte string')
TypeError: salt must be a byte string
Does anyone know how the salt would be edited so it becomes a byte string or is there a better alternative? Also, not that it matters since I have very little programming knowledge, why does the script need all the following to crack the seed words? - password, salt, N, r, p, olen
The good news is the "check args" password script part passed. Here's the code I mentioned earlier about all the possibilities for errors to be thrown:
if not isinstance(password, bytes):
raise TypeError('password must be a byte string')
if not isinstance(salt, bytes):
raise TypeError('salt must be a byte string')
if not isinstance(N, numbers.Integral):
raise TypeError('N must be an integer')
if not isinstance(r, numbers.Integral):
raise TypeError('r must be an integer')
if not isinstance(p, numbers.Integral):
raise TypeError('p must be an integer')
if not isinstance(olen, numbers.Integral):
raise TypeError('length must be an integer')
if N > 2**63:
raise ValueError('N cannot be larger than 2**63')
if (N & (N - 1)) or N < 2:
raise ValueError('N must be a power of two larger than 1')
if r <= 0:
raise ValueError('r must be positive')
if p <= 0:
raise ValueError('p must be positive')
if r * p >= 2**30:
raise ValueError('r * p must be less than 2 ** 30')
if olen <= 0:
raise ValueError('length must be positive')
If other errors arise, I will post them here; but I'm hoping it will just work and return my seed words!
Prelude
I guess I've come up with the solution not to help myself only but to help someone one day. Had the same issue long time ago. As I understood from the question:
the main goal is to recover a seed (12-words phrase) which you will always need in order to restore your wallet and to get a full access to it, in particular sending funds (don't confuse with watch-only wallet mode like if you were using public key / wallet address to recover the wallet);
a solution does not have to be related with use of Python.
I dedicate this answer to all my brothers in misfortune who have wallets in MultibitHD which is no longer supported (Multibit is Deprecated - Do Not Use) and was abandonded with its unresolved issues like:
unconfirmed transactions;
frequent wallet repairing;
synchronization issues;
errors when entering the correct password;
backup failures etc.
Guide
We'll use the special utility which is stored as mbexport in npm (Node package manager) registry. Install mbexport package globally via npm which is installable with Node.js (npm install -g mbexport).
Next, you need to determine the path to the MultibitHD wallet file in your file system.
Generally, for Windows it is:
C:/Users/username/AppData/Roaming/MultiBitHD/wallet-id/mbhd.wallet.aes
For MacOS it is:
~/Library/Application Support/MultiBitHD/wallet-id/mbhd.wallet.aes
Where username is your Windows user, wallet-id is unique wallet identifier (starts with mbhd-)
A little hint: you can find out the path in MultibitHD application, if you can enter the wallet and know the password that you might have set. It's quite convenient especially when you have several wallets. Just navigate to Manage wallet -> Wallet dashboard.
Then you need to open a command prompt and enter the command below. path-to-wallet-file is the previously found path to the wallet.
Please note: I personally did not get the error Error opening wallet file only when I dragged the wallet file from the explorer right into the command prompt so that it became a full valid path. Also I recommend you turning off the Internet while getting the seed. Although I haven't found any issues in the source code of mbexport that dealt with sending sensitive data accross the Internet, it's a simple security matter.
mbexport path-to-wallet-file
Congratulations, you have finally got the seed! Don't share it with anyone and make sure you keep it in safe and wrote it on a physical paper as it is your key to your funds!
Restoring your wallet from the seed
Although it is not part of the question, you will probably want to know how you can restore your wallet with the seed, for example, in Electrum. Follow this guide Restoring your MultibitHD Wallet in Electrum and keep in mind that the seed you got is in obsolete BIP39 format, the derivation path in MultibitHD is m/0' and the type of address is p2pkh.

Bash for loop - syntax error in expression (error token is "2")

I'm currently trying to find the bug in the following piece of bash code:
for ((v=1; v<=${config[vnc_number]}; v++))
do
# Do something here
done
for ((l=1; l<=${config[number]}; l++))
do
# And do something here
done
Inside the loops I'm just creating a few VMs but think this is irrelevant for this question.
The values of config[vnc_number] and config[number] are defined in another file but reading these out works just fine, I tried it.
The first loop works just fine but the wierd thing is that in the second loop it throws the error:
create_vms.sh: line 109: ((: l<=3
2: syntax error in expression (error token is "2")
I tried various things to fix it but nothing seems to work so I am asking you guys.
Thanks in advance for the help.

Resources