hexsha
string
size
int64
ext
string
lang
string
max_stars_repo_path
string
max_stars_repo_name
string
max_stars_repo_head_hexsha
string
max_stars_repo_licenses
list
max_stars_count
int64
max_stars_repo_stars_event_min_datetime
string
max_stars_repo_stars_event_max_datetime
string
max_issues_repo_path
string
max_issues_repo_name
string
max_issues_repo_head_hexsha
string
max_issues_repo_licenses
list
max_issues_count
int64
max_issues_repo_issues_event_min_datetime
string
max_issues_repo_issues_event_max_datetime
string
max_forks_repo_path
string
max_forks_repo_name
string
max_forks_repo_head_hexsha
string
max_forks_repo_licenses
list
max_forks_count
int64
max_forks_repo_forks_event_min_datetime
string
max_forks_repo_forks_event_max_datetime
string
content
string
avg_line_length
float64
max_line_length
int64
alphanum_fraction
float64
qsc_code_num_words_quality_signal
int64
qsc_code_num_chars_quality_signal
float64
qsc_code_mean_word_length_quality_signal
float64
qsc_code_frac_words_unique_quality_signal
float64
qsc_code_frac_chars_top_2grams_quality_signal
float64
qsc_code_frac_chars_top_3grams_quality_signal
float64
qsc_code_frac_chars_top_4grams_quality_signal
float64
qsc_code_frac_chars_dupe_5grams_quality_signal
float64
qsc_code_frac_chars_dupe_6grams_quality_signal
float64
qsc_code_frac_chars_dupe_7grams_quality_signal
float64
qsc_code_frac_chars_dupe_8grams_quality_signal
float64
qsc_code_frac_chars_dupe_9grams_quality_signal
float64
qsc_code_frac_chars_dupe_10grams_quality_signal
float64
qsc_code_frac_chars_replacement_symbols_quality_signal
float64
qsc_code_frac_chars_digital_quality_signal
float64
qsc_code_frac_chars_whitespace_quality_signal
float64
qsc_code_size_file_byte_quality_signal
float64
qsc_code_num_lines_quality_signal
float64
qsc_code_num_chars_line_max_quality_signal
float64
qsc_code_num_chars_line_mean_quality_signal
float64
qsc_code_frac_chars_alphabet_quality_signal
float64
qsc_code_frac_chars_comments_quality_signal
float64
qsc_code_cate_xml_start_quality_signal
float64
qsc_code_frac_lines_dupe_lines_quality_signal
float64
qsc_code_cate_autogen_quality_signal
float64
qsc_code_frac_lines_long_string_quality_signal
float64
qsc_code_frac_chars_string_length_quality_signal
float64
qsc_code_frac_chars_long_word_length_quality_signal
float64
qsc_code_frac_lines_string_concat_quality_signal
float64
qsc_code_cate_encoded_data_quality_signal
float64
qsc_code_frac_chars_hex_words_quality_signal
float64
qsc_code_frac_lines_prompt_comments_quality_signal
float64
qsc_code_frac_lines_assert_quality_signal
float64
qsc_codepython_cate_ast_quality_signal
float64
qsc_codepython_frac_lines_func_ratio_quality_signal
float64
qsc_codepython_cate_var_zero_quality_signal
bool
qsc_codepython_frac_lines_pass_quality_signal
float64
qsc_codepython_frac_lines_import_quality_signal
float64
qsc_codepython_frac_lines_simplefunc_quality_signal
float64
qsc_codepython_score_lines_no_logic_quality_signal
float64
qsc_codepython_frac_lines_print_quality_signal
float64
qsc_code_num_words
int64
qsc_code_num_chars
int64
qsc_code_mean_word_length
int64
qsc_code_frac_words_unique
null
qsc_code_frac_chars_top_2grams
int64
qsc_code_frac_chars_top_3grams
int64
qsc_code_frac_chars_top_4grams
int64
qsc_code_frac_chars_dupe_5grams
int64
qsc_code_frac_chars_dupe_6grams
int64
qsc_code_frac_chars_dupe_7grams
int64
qsc_code_frac_chars_dupe_8grams
int64
qsc_code_frac_chars_dupe_9grams
int64
qsc_code_frac_chars_dupe_10grams
int64
qsc_code_frac_chars_replacement_symbols
int64
qsc_code_frac_chars_digital
int64
qsc_code_frac_chars_whitespace
int64
qsc_code_size_file_byte
int64
qsc_code_num_lines
int64
qsc_code_num_chars_line_max
int64
qsc_code_num_chars_line_mean
int64
qsc_code_frac_chars_alphabet
int64
qsc_code_frac_chars_comments
int64
qsc_code_cate_xml_start
int64
qsc_code_frac_lines_dupe_lines
int64
qsc_code_cate_autogen
int64
qsc_code_frac_lines_long_string
int64
qsc_code_frac_chars_string_length
int64
qsc_code_frac_chars_long_word_length
int64
qsc_code_frac_lines_string_concat
null
qsc_code_cate_encoded_data
int64
qsc_code_frac_chars_hex_words
int64
qsc_code_frac_lines_prompt_comments
int64
qsc_code_frac_lines_assert
int64
qsc_codepython_cate_ast
int64
qsc_codepython_frac_lines_func_ratio
int64
qsc_codepython_cate_var_zero
int64
qsc_codepython_frac_lines_pass
int64
qsc_codepython_frac_lines_import
int64
qsc_codepython_frac_lines_simplefunc
int64
qsc_codepython_score_lines_no_logic
int64
qsc_codepython_frac_lines_print
int64
effective
string
hits
int64
be99fbf28c16ccbaed439d34cdc69d206ecb3390
156
py
Python
src/uri/basic/basic_1005.py
gabrielDpadua21/code-challenges
0050bc9b358193aa6cacdda21e0670a9dc20450a
[ "MIT" ]
null
null
null
src/uri/basic/basic_1005.py
gabrielDpadua21/code-challenges
0050bc9b358193aa6cacdda21e0670a9dc20450a
[ "MIT" ]
null
null
null
src/uri/basic/basic_1005.py
gabrielDpadua21/code-challenges
0050bc9b358193aa6cacdda21e0670a9dc20450a
[ "MIT" ]
null
null
null
class SimpleMean: def solution(self, value1, value2): mean = ((value1 * 3.5) + (value2 * 7.5)) / 11 return "MEDIA = " + "%.5f" % (mean)
31.2
53
0.519231
19
156
4.263158
0.789474
0
0
0
0
0
0
0
0
0
0
0.099099
0.288462
156
5
54
31.2
0.630631
0
0
0
0
0
0.076433
0
0
0
0
0
0
1
0.25
false
0
0
0
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
4
bea510a05f5b6868d8a68e554779d52f32537606
44
py
Python
_solved/solutions/case-conflict-mapping41.py
lleondia/geopandas-tutorial
5128fd6865bbd979a7b4e5b8cb4d0de51bead029
[ "BSD-3-Clause" ]
341
2018-04-26T08:46:05.000Z
2022-03-01T08:13:39.000Z
_solved/solutions/case-conflict-mapping41.py
lleondia/geopandas-tutorial
5128fd6865bbd979a7b4e5b8cb4d0de51bead029
[ "BSD-3-Clause" ]
22
2018-06-15T23:19:27.000Z
2020-03-23T11:08:55.000Z
_solved/solutions/case-conflict-mapping41.py
lleondia/geopandas-tutorial
5128fd6865bbd979a7b4e5b8cb4d0de51bead029
[ "BSD-3-Clause" ]
197
2018-06-15T18:34:53.000Z
2022-02-27T11:33:15.000Z
data_within_border['NAME_AP'].value_counts()
44
44
0.840909
7
44
4.714286
1
0
0
0
0
0
0
0
0
0
0
0
0
44
1
44
44
0.75
0
0
0
0
0
0.155556
0
0
0
0
0
0
1
0
true
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
fe6b3f41597af4261d840b50f1d04d27c3333e5c
262
py
Python
codingbat/Python/Warmup-1/sum_double.py
bittti/programming-practice
9336cd5089be90676203df945960320589613c89
[ "MIT" ]
null
null
null
codingbat/Python/Warmup-1/sum_double.py
bittti/programming-practice
9336cd5089be90676203df945960320589613c89
[ "MIT" ]
null
null
null
codingbat/Python/Warmup-1/sum_double.py
bittti/programming-practice
9336cd5089be90676203df945960320589613c89
[ "MIT" ]
null
null
null
# coding: utf-8 """ Given two int values, return their sum. Unless the two values are the same, then return double their sum. sum_double(1, 2) → 3 sum_double(3, 2) → 5 sum_double(2, 2) → 8 """ def sum_double(a, b): return (a + b if a != b else (a+b) * 2)
18.714286
80
0.633588
55
262
3
0.472727
0.218182
0
0
0
0
0
0
0
0
0
0.053922
0.221374
262
13
81
20.153846
0.740196
0.70229
0
0
0
0
0
0
0
0
0
0
0
1
0.5
false
0
0
0.5
1
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
1
0
0
4
fe79e881ca3b8ec9d1f2719d0cdb2d5eb9e70fd2
156
py
Python
app/settings_prod.py
vollov/ocbl-rest
79509c027dc84f5dddf59cea832881ca95879e31
[ "MIT" ]
null
null
null
app/settings_prod.py
vollov/ocbl-rest
79509c027dc84f5dddf59cea832881ca95879e31
[ "MIT" ]
null
null
null
app/settings_prod.py
vollov/ocbl-rest
79509c027dc84f5dddf59cea832881ca95879e31
[ "MIT" ]
null
null
null
from settings import * DEBUG = CAPTCHA_TEST_MODE = TEMPLATE_DEBUG = False ALLOWED_HOSTS = ['127.0.0.1', 'localhost', 'doonvalley.ca', 'www.doonvalley.ca']
31.2
80
0.730769
22
156
5
0.818182
0.218182
0
0
0
0
0
0
0
0
0
0.043478
0.115385
156
4
81
39
0.753623
0
0
0
0
0
0.307692
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.333333
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
fe7f28a3901747795035b491af5dad565216aefa
2,142
py
Python
sdk/python/pulumi_aws_native/docdb/outputs.py
AaronFriel/pulumi-aws-native
5621690373ac44accdbd20b11bae3be1baf022d1
[ "Apache-2.0" ]
29
2021-09-30T19:32:07.000Z
2022-03-22T21:06:08.000Z
sdk/python/pulumi_aws_native/docdb/outputs.py
AaronFriel/pulumi-aws-native
5621690373ac44accdbd20b11bae3be1baf022d1
[ "Apache-2.0" ]
232
2021-09-30T19:26:26.000Z
2022-03-31T23:22:06.000Z
sdk/python/pulumi_aws_native/docdb/outputs.py
AaronFriel/pulumi-aws-native
5621690373ac44accdbd20b11bae3be1baf022d1
[ "Apache-2.0" ]
4
2021-11-10T19:42:01.000Z
2022-02-05T10:15:49.000Z
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi SDK Generator. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import warnings import pulumi import pulumi.runtime from typing import Any, Mapping, Optional, Sequence, Union, overload from .. import _utilities __all__ = [ 'DBClusterParameterGroupTag', 'DBClusterTag', 'DBInstanceTag', 'DBSubnetGroupTag', ] @pulumi.output_type class DBClusterParameterGroupTag(dict): def __init__(__self__, *, key: str, value: str): pulumi.set(__self__, "key", key) pulumi.set(__self__, "value", value) @property @pulumi.getter def key(self) -> str: return pulumi.get(self, "key") @property @pulumi.getter def value(self) -> str: return pulumi.get(self, "value") @pulumi.output_type class DBClusterTag(dict): def __init__(__self__, *, key: str, value: str): pulumi.set(__self__, "key", key) pulumi.set(__self__, "value", value) @property @pulumi.getter def key(self) -> str: return pulumi.get(self, "key") @property @pulumi.getter def value(self) -> str: return pulumi.get(self, "value") @pulumi.output_type class DBInstanceTag(dict): def __init__(__self__, *, key: str, value: str): pulumi.set(__self__, "key", key) pulumi.set(__self__, "value", value) @property @pulumi.getter def key(self) -> str: return pulumi.get(self, "key") @property @pulumi.getter def value(self) -> str: return pulumi.get(self, "value") @pulumi.output_type class DBSubnetGroupTag(dict): def __init__(__self__, *, key: str, value: str): pulumi.set(__self__, "key", key) pulumi.set(__self__, "value", value) @property @pulumi.getter def key(self) -> str: return pulumi.get(self, "key") @property @pulumi.getter def value(self) -> str: return pulumi.get(self, "value")
22.787234
80
0.59197
240
2,142
4.979167
0.2375
0.070293
0.087029
0.153975
0.671967
0.671967
0.671967
0.671967
0.671967
0.671967
0
0.000651
0.282913
2,142
93
81
23.032258
0.777344
0.075163
0
0.788732
1
0
0.066329
0.013165
0
0
0
0
0
1
0.169014
false
0
0.070423
0.112676
0.408451
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
null
0
0
0
0
0
0
0
0
0
1
0
0
0
4
feb7a27227a6e66242abe06e4c1f18817542bcb7
11,148
py
Python
tensorflow/python/training/ftrl_test.py
connectthefuture/tensorflow
93812423fcd5878aa2c1d0b68dc0496980c8519d
[ "Apache-2.0" ]
101
2016-12-03T11:40:52.000Z
2017-12-23T02:02:03.000Z
tensorflow/python/training/ftrl_test.py
connectthefuture/tensorflow
93812423fcd5878aa2c1d0b68dc0496980c8519d
[ "Apache-2.0" ]
9
2016-12-14T03:27:46.000Z
2017-09-13T02:29:07.000Z
tensorflow/python/training/ftrl_test.py
connectthefuture/tensorflow
93812423fcd5878aa2c1d0b68dc0496980c8519d
[ "Apache-2.0" ]
47
2016-12-04T12:37:24.000Z
2018-01-14T18:13:07.000Z
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Functional tests for Ftrl operations.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf class FtrlOptimizerTest(tf.test.TestCase): def testFtrlwithoutRegularization(self): for dtype in [tf.half, tf.float32]: with self.test_session() as sess: var0 = tf.Variable([0.0, 0.0], dtype=dtype) var1 = tf.Variable([0.0, 0.0], dtype=dtype) grads0 = tf.constant([0.1, 0.2], dtype=dtype) grads1 = tf.constant([0.01, 0.02], dtype=dtype) opt = tf.train.FtrlOptimizer(3.0, initial_accumulator_value=0.1, l1_regularization_strength=0.0, l2_regularization_strength=0.0) update = opt.apply_gradients(zip([grads0, grads1], [var0, var1])) tf.global_variables_initializer().run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllClose([0.0, 0.0], v0_val) self.assertAllClose([0.0, 0.0], v1_val) # Run 3 steps FTRL for _ in range(3): update.run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType(np.array([-2.60260963, -4.29698515]), v0_val) self.assertAllCloseAccordingToType(np.array([-0.28432083, -0.56694895]), v1_val) def testFtrlwithoutRegularization2(self): for dtype in [tf.half, tf.float32]: with self.test_session() as sess: var0 = tf.Variable([1.0, 2.0], dtype=dtype) var1 = tf.Variable([4.0, 3.0], dtype=dtype) grads0 = tf.constant([0.1, 0.2], dtype=dtype) grads1 = tf.constant([0.01, 0.02], dtype=dtype) opt = tf.train.FtrlOptimizer(3.0, initial_accumulator_value=0.1, l1_regularization_strength=0.0, l2_regularization_strength=0.0) update = opt.apply_gradients(zip([grads0, grads1], [var0, var1])) tf.global_variables_initializer().run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType([1.0, 2.0], v0_val) self.assertAllCloseAccordingToType([4.0, 3.0], v1_val) # Run 3 steps FTRL for _ in range(3): update.run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType(np.array([-2.55607247, -3.98729396]), v0_val) self.assertAllCloseAccordingToType(np.array([-0.28232238, -0.56096673]), v1_val) def testFtrlWithL1(self): for dtype in [tf.half, tf.float32]: with self.test_session() as sess: var0 = tf.Variable([1.0, 2.0], dtype=dtype) var1 = tf.Variable([4.0, 3.0], dtype=dtype) grads0 = tf.constant([0.1, 0.2], dtype=dtype) grads1 = tf.constant([0.01, 0.02], dtype=dtype) opt = tf.train.FtrlOptimizer(3.0, initial_accumulator_value=0.1, l1_regularization_strength=0.001, l2_regularization_strength=0.0) update = opt.apply_gradients(zip([grads0, grads1], [var0, var1])) tf.global_variables_initializer().run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType([1.0, 2.0], v0_val) self.assertAllCloseAccordingToType([4.0, 3.0], v1_val) # Run 10 steps FTRL for _ in range(10): update.run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType( np.array([-7.66718769, -10.91273689]), v0_val) self.assertAllCloseAccordingToType( np.array([-0.93460727, -1.86147261]), v1_val) def testFtrlWithL1_L2(self): for dtype in [tf.half, tf.float32]: with self.test_session() as sess: var0 = tf.Variable([1.0, 2.0], dtype=dtype) var1 = tf.Variable([4.0, 3.0], dtype=dtype) grads0 = tf.constant([0.1, 0.2], dtype=dtype) grads1 = tf.constant([0.01, 0.02], dtype=dtype) opt = tf.train.FtrlOptimizer(3.0, initial_accumulator_value=0.1, l1_regularization_strength=0.001, l2_regularization_strength=2.0) update = opt.apply_gradients(zip([grads0, grads1], [var0, var1])) tf.global_variables_initializer().run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType([1.0, 2.0], v0_val) self.assertAllCloseAccordingToType([4.0, 3.0], v1_val) # Run 10 steps FTRL for _ in range(10): update.run() v0_val, v1_val = sess.run([var0, var1]) self.assertAllCloseAccordingToType(np.array([-0.24059935, -0.46829352]), v0_val) self.assertAllCloseAccordingToType(np.array([-0.02406147, -0.04830509]), v1_val) def applyOptimizer(self, opt, dtype, steps=5, is_sparse=False): if is_sparse: var0 = tf.Variable([[0.0], [0.0]], dtype=dtype) var1 = tf.Variable([[0.0], [0.0]], dtype=dtype) grads0 = tf.IndexedSlices(tf.constant([0.1], shape=[1, 1], dtype=dtype), tf.constant([0]), tf.constant([2, 1])) grads1 = tf.IndexedSlices(tf.constant([0.02], shape=[1, 1], dtype=dtype), tf.constant([1]), tf.constant([2, 1])) else: var0 = tf.Variable([0.0, 0.0], dtype=dtype) var1 = tf.Variable([0.0, 0.0], dtype=dtype) grads0 = tf.constant([0.1, 0.2], dtype=dtype) grads1 = tf.constant([0.01, 0.02], dtype=dtype) update = opt.apply_gradients(zip([grads0, grads1], [var0, var1])) tf.global_variables_initializer().run() sess = tf.get_default_session() v0_val, v1_val = sess.run([var0, var1]) if is_sparse: self.assertAllCloseAccordingToType([[0.0], [0.0]], v0_val) self.assertAllCloseAccordingToType([[0.0], [0.0]], v1_val) else: self.assertAllCloseAccordingToType([0.0, 0.0], v0_val) self.assertAllCloseAccordingToType([0.0, 0.0], v1_val) # Run Ftrl for a few steps for _ in range(steps): update.run() v0_val, v1_val = sess.run([var0, var1]) return v0_val, v1_val # When variables are initialized with Zero, FTRL-Proximal has two properties: # 1. Without L1&L2 but with fixed learning rate, FTRL-Proximal is identical # with GradientDescent. # 2. Without L1&L2 but with adaptive learning rate, FTRL-Proximal is identical # with Adagrad. # So, basing on these two properties, we test if our implementation of # FTRL-Proximal performs same updates as Adagrad or GradientDescent. def testEquivAdagradwithoutRegularization(self): for dtype in [tf.half, tf.float32]: with self.test_session(): val0, val1 = self.applyOptimizer( tf.train.FtrlOptimizer(3.0, # Adagrad learning rate learning_rate_power=-0.5, initial_accumulator_value=0.1, l1_regularization_strength=0.0, l2_regularization_strength=0.0), dtype) with self.test_session(): val2, val3 = self.applyOptimizer( tf.train.AdagradOptimizer(3.0, initial_accumulator_value=0.1), dtype) self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) def testEquivSparseAdagradwithoutRegularization(self): for dtype in [tf.half, tf.float32]: with self.test_session(): val0, val1 = self.applyOptimizer( tf.train.FtrlOptimizer(3.0, # Adagrad learning rate learning_rate_power=-0.5, initial_accumulator_value=0.1, l1_regularization_strength=0.0, l2_regularization_strength=0.0), dtype, is_sparse=True) with self.test_session(): val2, val3 = self.applyOptimizer( tf.train.AdagradOptimizer(3.0, initial_accumulator_value=0.1), dtype, is_sparse=True) self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) def testEquivSparseGradientDescentwithoutRegularization(self): for dtype in [tf.half, tf.float32]: with self.test_session(): val0, val1 = self.applyOptimizer( tf.train.FtrlOptimizer(3.0, # Fixed learning rate learning_rate_power=-0.0, initial_accumulator_value=0.1, l1_regularization_strength=0.0, l2_regularization_strength=0.0), dtype, is_sparse=True) with self.test_session(): val2, val3 = self.applyOptimizer( tf.train.GradientDescentOptimizer(3.0), dtype, is_sparse=True) self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) def testEquivGradientDescentwithoutRegularization(self): for dtype in [tf.half, tf.float32]: with self.test_session(): val0, val1 = self.applyOptimizer( tf.train.FtrlOptimizer(3.0, # Fixed learning rate learning_rate_power=-0.0, initial_accumulator_value=0.1, l1_regularization_strength=0.0, l2_regularization_strength=0.0), dtype) with self.test_session(): val2, val3 = self.applyOptimizer( tf.train.GradientDescentOptimizer(3.0), dtype) self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) if __name__ == "__main__": tf.test.main()
41.752809
80
0.572659
1,283
11,148
4.846454
0.156664
0.016404
0.011579
0.050177
0.758122
0.74413
0.739627
0.685751
0.68173
0.654873
0
0.077444
0.310818
11,148
266
81
41.909774
0.731876
0.11455
0
0.774359
0
0
0.000813
0
0
0
0
0
0.14359
1
0.046154
false
0
0.025641
0
0.082051
0.005128
0
0
0
null
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
22b56be48d0423e53e3b7b099d0a142c42d21cc7
85
py
Python
Python/04. Sets/012. Check Subset.py
stonehengee/HackerrankPractice
ec052e7447391e40d1919cf0b641ff5023da3da3
[ "MIT" ]
null
null
null
Python/04. Sets/012. Check Subset.py
stonehengee/HackerrankPractice
ec052e7447391e40d1919cf0b641ff5023da3da3
[ "MIT" ]
null
null
null
Python/04. Sets/012. Check Subset.py
stonehengee/HackerrankPractice
ec052e7447391e40d1919cf0b641ff5023da3da3
[ "MIT" ]
null
null
null
# Problem: https://www.hackerrank.com/challenges/py-check-subset/problem # Score: 10
28.333333
72
0.764706
12
85
5.416667
0.916667
0
0
0
0
0
0
0
0
0
0
0.025316
0.070588
85
2
73
42.5
0.797468
0.941176
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
22c1123ec1408addcc5f61178e992e58a86ead40
1,625
py
Python
stats/support/web_api/session.py
vyahello/nba_stats
db16d84898dc7ee1b1a2dac513675dee9570c8ec
[ "MIT" ]
3
2019-11-08T21:56:36.000Z
2021-12-26T20:23:29.000Z
stats/support/web_api/session.py
vyahello/nba_stats
db16d84898dc7ee1b1a2dac513675dee9570c8ec
[ "MIT" ]
3
2019-11-09T16:11:51.000Z
2019-11-09T16:14:37.000Z
stats/support/web_api/session.py
vyahello/nba_stats
db16d84898dc7ee1b1a2dac513675dee9570c8ec
[ "MIT" ]
1
2021-04-01T12:33:46.000Z
2021-04-01T12:33:46.000Z
from abc import ABC, abstractmethod from typing import Dict, Any, Callable import requests from stats.support.web_api.responses import Response, BotResponse, ResponseError from stats.support.web_api.urls import Url class Session(ABC): """Abstract interfaces for API Session.""" @abstractmethod def get(self) -> Response: pass @abstractmethod def post(self, data: Dict[Any, Any]) -> Response: pass class _BotSession(Session): """Provide interfaces for bot api session.""" def __init__(self, url: Url) -> None: self._api: requests.Session = requests.Session() self._url = url def get(self) -> Response: return BotResponse(self._api.get(str(self._url))) def post(self, data: Dict[Any, Any]) -> Response: return BotResponse(self._api.post(str(self._url), json=data)) class SafeBotSession(Session): """Provide interfaces for safe bot api session. Raise an error if specific HTTP status code is not presented. """ def __init__(self, url: Url, codes: int = (200, 204)) -> None: def safe(response: Response) -> Response: code: int = response.status_code() if code not in codes: raise ResponseError(f'HTTP response error with {code} status code!!!') return response self._session: Session = _BotSession(url) self._safe: Callable[[Response], Response] = safe def get(self) -> Response: return self._safe(self._session.get()) def post(self, data: Dict[Any, Any]) -> Response: return self._safe(self._session.post(data))
29.545455
86
0.652923
203
1,625
5.103448
0.285714
0.033784
0.028958
0.052124
0.300193
0.157336
0.107143
0.107143
0.07529
0
0
0.004812
0.232615
1,625
54
87
30.092593
0.825982
0.112615
0
0.30303
0
0
0.032463
0
0
0
0
0
0
1
0.272727
false
0.060606
0.151515
0.121212
0.666667
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
1
0
1
1
0
0
4
22ca3b3afd330cdbdf2ac5e3f764d56d96208291
19,402
py
Python
tests/test_ast_symbol_extractor.py
CJ-Wright-Citadel/symbol-exporter
a7b720b2f19ddce51ee743f1ce7a61b0cb38ee15
[ "BSD-3-Clause" ]
2
2021-04-26T22:59:32.000Z
2021-11-10T18:42:07.000Z
tests/test_ast_symbol_extractor.py
CJ-Wright-Citadel/symbol-exporter
a7b720b2f19ddce51ee743f1ce7a61b0cb38ee15
[ "BSD-3-Clause" ]
81
2021-01-29T17:17:24.000Z
2021-09-27T23:10:27.000Z
tests/test_ast_symbol_extractor.py
CJ-Wright-Citadel/symbol-exporter
a7b720b2f19ddce51ee743f1ce7a61b0cb38ee15
[ "BSD-3-Clause" ]
8
2021-01-29T23:30:28.000Z
2021-08-05T02:24:53.000Z
import ast from textwrap import dedent from symbol_exporter.ast_symbol_extractor import SymbolFinder, SymbolType def process_code_str(code, module_name="mm"): tree = ast.parse(dedent(code)) z = SymbolFinder(module_name=module_name) z.visit(tree) return z def test_package_name(): code = """ from abc import xyz """ z = process_code_str(code, module_name="__init__") assert z.symbols == { "__init__": { "data": {"symbols_in_volume": {"abc.xyz": {"line number": [2]}}}, "type": SymbolType.PACKAGE, }, "__init__.xyz": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, } def test_fully_qualified_package_names(): code = """ from abc import xyz """ z = process_code_str(code, module_name="mm.__init__") assert z.symbols == { "mm.__init__": { "data": {"symbols_in_volume": {"abc.xyz": {"line number": [2]}}}, "type": SymbolType.PACKAGE, }, "mm.__init__.xyz": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, } def test_fully_qualified_module_names(): code = """ from abc import xyz """ z = process_code_str(code, module_name="mm.core") assert z.symbols == { "mm.core": { "data": {"symbols_in_volume": {"abc.xyz": {"line number": [2]}}}, "type": SymbolType.MODULE, }, "mm.core.xyz": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, } def test_from_import_attr_access(): code = """ from abc import xyz def f(): return xyz.i """ z = process_code_str(code) assert z.aliases == {"xyz": "abc.xyz"} assert z.imported_symbols == ["abc.xyz"] assert z.used_symbols == {"abc.xyz.i"} assert z.symbols == { "mm": { "data": {"symbols_in_volume": {"abc.xyz": {"line number": [2]}}}, "type": SymbolType.MODULE, }, "mm.xyz": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, "mm.f": { "type": SymbolType.FUNCTION, "data": { "lineno": 4, "symbols_in_volume": {"abc.xyz.i": {"line number": [5]}}, }, }, } def test_import_in_function(): code = """ def f(): from abc import xyz return xyz.i """ z = process_code_str(code) assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {}, }, "mm.f": { "type": SymbolType.FUNCTION, "data": { "lineno": 2, "symbols_in_volume": {"abc.xyz.i": {"line number": [4]}, "abc.xyz": {"line number": [3]}}, }, }, } def test_alias_import(): code = """ from abc import xyz as l def f(): return l.i """ z = process_code_str(code) assert z.aliases == {"xyz": "abc.xyz", "l": "abc.xyz"} assert z.imported_symbols == ["abc.xyz"] assert z.used_symbols == {"abc.xyz.i"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"abc.xyz": {"line number": [2]}}}, }, "mm.l": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, "mm.f": { "type": SymbolType.FUNCTION, "data": { "lineno": 4, "symbols_in_volume": {"abc.xyz.i": {"line number": [5]}}, }, }, } def test_import_with_and_without_alias_exposes_import_and_alias(): code = """ from abc import xyz from abc import xyz as l def f(): return l.i """ z = process_code_str(code) assert z.aliases == {"xyz": "abc.xyz", "l": "abc.xyz"} assert z.imported_symbols == ["abc.xyz", "abc.xyz"] assert z.used_symbols == {"abc.xyz.i"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"abc.xyz": {"line number": [2, 3]}}}, }, "mm.f": { "type": SymbolType.FUNCTION, "data": { "lineno": 5, "symbols_in_volume": {"abc.xyz.i": {"line number": [6]}}, }, }, "mm.xyz": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, "mm.l": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, } def test_calls(): code = """ import numpy as np def f(): return np.ones(np.twos().three) """ z = process_code_str(code) assert z.aliases == {"np": "numpy"} assert z.imported_symbols == ["numpy"] assert z.used_symbols == {"numpy.ones", "numpy.twos"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"numpy": {"line number": [2]}}}, }, "mm.f": { "type": SymbolType.FUNCTION, "data": { "lineno": 4, "symbols_in_volume": { "numpy.ones": {"line number": [5]}, "numpy.twos": {"line number": [5]}, }, }, }, "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, } def test_constant(): code = """ import numpy as np z = np.ones(5) """ z = process_code_str(code) assert z.aliases == {"np": "numpy"} assert z.imported_symbols == ["numpy"] assert z.used_symbols == {"numpy.ones"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"numpy.ones": {"line number": [4]}, "numpy": {"line number": [2]}}}, }, "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, "mm.z": { "type": SymbolType.CONSTANT, "data": {"lineno": 4}, }, } def test_class(): code = """ import numpy as np class ABC(): a = np.ones(5) """ z = process_code_str(code) assert z.aliases == {"np": "numpy"} assert z.imported_symbols == ["numpy"] assert z.used_symbols == {"numpy.ones"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"numpy": {"line number": [2]}}}, }, "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, "mm.ABC": { "type": SymbolType.CLASS, "data": { "lineno": 4, "symbols_in_volume": {"numpy.ones": {"line number": [5]}}, }, }, } def test_class_method(): code = """ import numpy as np class ABC(): a = np.ones(5) def xyz(self): return np.twos(10) """ z = process_code_str(code) assert z.aliases == {"np": "numpy"} assert z.imported_symbols == ["numpy"] assert z.used_symbols == {"numpy.ones", "numpy.twos"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"numpy": {"line number": [2]}}}, }, "mm.ABC": { "type": SymbolType.CLASS, "data": { "lineno": 4, "symbols_in_volume": {"numpy.ones": {"line number": [5]}}, }, }, "mm.ABC.xyz": { "type": SymbolType.FUNCTION, "data": { "lineno": 7, "symbols_in_volume": {"numpy.twos": {"line number": [8]}}, }, }, "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, } def test_import_adds_symbols(): code = """ import numpy as np from abc import xyz as l from ggg import efg import ghi z = np.ones(5) """ z = process_code_str(code) assert z.symbols == { "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, "mm.l": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.xyz"}, }, "mm.efg": { "type": SymbolType.IMPORT, "data": {"shadows": "ggg.efg"}, }, "mm.ghi": { "type": SymbolType.IMPORT, "data": {"shadows": "ghi"}, }, "mm": { "data": { "symbols_in_volume": { "abc.xyz": {"line number": [3]}, "ggg.efg": {"line number": [4]}, "ghi": {"line number": [5]}, "numpy": {"line number": [2]}, "numpy.ones": {"line number": [7]}, } }, "type": SymbolType.MODULE, }, "mm.z": { "type": SymbolType.CONSTANT, "data": {"lineno": 7}, }, } def test_star_import(): code = """ import numpy as np from abc import * """ z = process_code_str(code) assert z.aliases == {"np": "numpy"} assert z.imported_symbols == ["numpy"] assert not z.used_symbols assert z.symbols == { "mm.*": { "type": SymbolType.STAR_IMPORT, "data": {"imports": {"abc"}}, }, "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"abc": {"line number": [3]}, "numpy": {"line number": [2]}}}, }, } def test_relative_import(): code = """ from . import core from .core import ones from ..core import twos """ z = process_code_str(code) assert z.symbols == { "mm.core": { "type": SymbolType.RELATIVE_IMPORT, "data": {"shadows": "core", "level": 1, "module": "mm"}, }, "mm.ones": { "type": SymbolType.RELATIVE_IMPORT, "data": {"shadows": "core.ones", "level": 1, "module": "mm"}, }, "mm.twos": { "type": SymbolType.RELATIVE_IMPORT, "data": {"shadows": "core.twos", "level": 2, "module": "mm"}, }, "mm": { "type": SymbolType.MODULE, "data": {}, }, } def test_relative_alias_import(): code = """ from . import core as c from .core import ones as c_ones from ..core import twos as c_twos """ z = process_code_str(code) assert z.symbols == { "mm": {"data": {}, "type": SymbolType.MODULE}, "mm.c": { "type": SymbolType.RELATIVE_IMPORT, "data": {"shadows": "core", "level": 1, "module": "mm"}, }, "mm.c_ones": { "type": SymbolType.RELATIVE_IMPORT, "data": {"shadows": "core.ones", "level": 1, "module": "mm"}, }, "mm.c_twos": { "type": SymbolType.RELATIVE_IMPORT, "data": {"shadows": "core.twos", "level": 2, "module": "mm"}, }, } def test_relative_star_import(): code = """ from .core import * from ..numeric import * """ z = process_code_str(code) assert z.symbols == { "mm": {"data": {}, "type": SymbolType.MODULE}, "mm.~~RELATIVE~~.*": { "type": SymbolType.RELATIVE_STAR_IMPORT, "data": { "imports": [ { "shadows": "core", "level": 1, "module": "mm", }, { "shadows": "numeric", "level": 2, "module": "mm", }, ] }, }, } def test_bare_relative_star_import(): code = """ from . import * from .. import * """ z = process_code_str(code) assert z.symbols == { "mm": {"data": {}, "type": SymbolType.MODULE}, "mm.~~RELATIVE~~.*": { "type": SymbolType.RELATIVE_STAR_IMPORT, "data": { "imports": [ { "shadows": "__init__", "level": 1, "module": "mm", }, { "shadows": "__init__", "level": 2, "module": "mm", }, ] }, }, } def test_undeclared_symbols(): code = """ import numpy as np from abc import * from xyz import * a = np.ones(5) b = twos(10) """ z = process_code_str(code) assert z.aliases == {"np": "numpy"} assert z.imported_symbols == ["numpy"] assert z.used_symbols == {"numpy.ones", "twos"} assert z.undeclared_symbols == {"twos"} assert z.symbols == { "mm.*": { "type": SymbolType.STAR_IMPORT, "data": {"imports": {"abc", "xyz"}}, }, "mm": { "type": SymbolType.MODULE, "data": { "symbols_in_volume": { "abc": {"line number": [4]}, "numpy": {"line number": [2]}, "xyz": {"line number": [5]}, "numpy.ones": {"line number": [8]}, "twos": {"line number": [9]}, }, }, }, "mm.a": { "type": SymbolType.CONSTANT, "data": {"lineno": 8}, }, "mm.b": { "type": SymbolType.CONSTANT, "data": {"lineno": 9}, }, "mm.np": { "type": SymbolType.IMPORT, "data": {"shadows": "numpy"}, }, } def test_imported_symbols_not_treated_as_undeclared(): code = """ from abc import twos b = twos(10) """ z = process_code_str(code) assert z.aliases == {"twos": "abc.twos"} assert z.imported_symbols == ["abc.twos"] assert z.used_symbols == {"abc.twos"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": {"symbols_in_volume": {"abc.twos": {"line number": [2, 4]}}}, }, "mm.twos": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.twos"}, }, "mm.b": { "type": SymbolType.CONSTANT, "data": {"lineno": 4}, }, } assert not z.undeclared_symbols def test_builtin_symbols_not_treated_as_undeclared(): code = """ from abc import twos b = len([]) """ z = process_code_str(code) assert z.aliases == {"twos": "abc.twos"} assert z.imported_symbols == ["abc.twos"] assert z.used_symbols == {"len"} assert z.used_builtins == {"len"} assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": { "symbols_in_volume": {"len": {"line number": [4]}, "abc.twos": {"line number": [2]}}, }, }, "mm.twos": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.twos"}, }, "mm.b": { "type": SymbolType.CONSTANT, "data": {"lineno": 4}, }, } assert not z.undeclared_symbols def test_functions_not_treated_as_undeclared(): code = """ from abc import twos def f(): return 1 g = f() """ z = process_code_str(code) assert z.aliases == {"twos": "abc.twos"} assert z.imported_symbols == ["abc.twos"] assert z.used_symbols == {"mm.f"} assert not z.used_builtins assert z.symbols == { "mm": { "type": SymbolType.MODULE, "data": { "symbols_in_volume": {"mm.f": {"line number": [7]}, "abc.twos": {"line number": [2]}}, }, }, "mm.f": { "type": SymbolType.FUNCTION, "data": {"lineno": 4}, }, "mm.twos": { "type": SymbolType.IMPORT, "data": {"shadows": "abc.twos"}, }, "mm.g": { "type": SymbolType.CONSTANT, "data": {"lineno": 7}, }, } assert not z.undeclared_symbols def test_attr_assignment(): code = """ from abc import twos twos.three = '*' twos.four = None """ z = process_code_str(code) assert z.symbols == { "mm": { "data": { "symbols_in_volume": { "abc.twos": {"line number": [2]}, "abc.twos.three": {"line number": [4]}, "abc.twos.four": {"line number": [5]}, } }, "type": SymbolType.MODULE, }, "mm.twos": {"data": {"shadows": "abc.twos"}, "type": SymbolType.IMPORT}, } def test_out_of_order_func_def(): code = """ def a(): return b() def b(): return 1 """ z = process_code_str(code) assert z.post_process_symbols() == { "mm": {"data": {}, "type": SymbolType.MODULE}, "mm.a": { "data": {"lineno": 2, "symbols_in_volume": {"mm.b": {"line number": [3]}}}, "type": SymbolType.FUNCTION, }, "mm.b": {"data": {"lineno": 5}, "type": SymbolType.FUNCTION}, } def test_multi_use_of_symbol(): code = """ def a(): a = ones(5) b = ones(5) return a + b """ z = process_code_str(code) assert z.post_process_symbols() == { "mm": {"data": {}, "type": SymbolType.MODULE}, "mm.a": { "data": { "lineno": 2, "symbols_in_volume": {"ones": {"line number": [3, 4]}}, }, "type": SymbolType.FUNCTION, }, } def test_self_is_callable(): code = """ class A: def a(self, job_name_class=None): self() def b(self): self.z = self.x """ z = process_code_str(code) assert z.undeclared_symbols == set() assert z.post_process_symbols() == { "mm": {"data": {}, "type": SymbolType.MODULE}, "mm.A": {"data": {"lineno": 2}, "type": SymbolType.CLASS}, "mm.A.a": {"data": {"lineno": 3}, "type": SymbolType.FUNCTION}, "mm.A.b": {"data": {"lineno": 5}, "type": SymbolType.FUNCTION}, } def test_symbols_in_volume_names(): code = """ import ast z = [ast.Try] z.sort() """ z = process_code_str(code) assert z.undeclared_symbols == set() assert z.post_process_symbols() == { "mm": { "data": { "symbols_in_volume": { "ast.Try": {"line number": [4]}, "ast": {"line number": [2]}, "mm.z": {"line number": [5]}, } }, "type": SymbolType.MODULE, }, "mm.ast": {"data": {"shadows": "ast"}, "type": SymbolType.IMPORT}, "mm.z": {"data": {"lineno": 4}, "type": SymbolType.CONSTANT}, }
26.433243
111
0.44248
1,912
19,402
4.335251
0.059623
0.136808
0.052479
0.058632
0.81578
0.745446
0.727229
0.686331
0.671854
0.620099
0
0.008005
0.375477
19,402
733
112
26.469304
0.676075
0
0
0.603945
0
0
0.272549
0.002319
0
0
0
0
0.106222
1
0.040971
false
0
0.14871
0
0.206373
0
0
0
0
null
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
22d2465bff4dc9dafc42ff7aa6f7ba3d9aeac00f
119
py
Python
redbird/repos/__init__.py
Miksus/red-base
4c272e8cb2325b51f6293f608a773e011b1d05da
[ "MIT" ]
null
null
null
redbird/repos/__init__.py
Miksus/red-base
4c272e8cb2325b51f6293f608a773e011b1d05da
[ "MIT" ]
null
null
null
redbird/repos/__init__.py
Miksus/red-base
4c272e8cb2325b51f6293f608a773e011b1d05da
[ "MIT" ]
null
null
null
from .memory import MemoryRepo from .mongo import MongoRepo from .sqlalchemy import SQLRepo from .rest import RESTRepo
23.8
31
0.831933
16
119
6.1875
0.625
0
0
0
0
0
0
0
0
0
0
0
0.134454
119
5
32
23.8
0.961165
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
22d615436299f6bcc495a7bc5e4d9b70ece15481
161
py
Python
remote-coding-platform-manager-service/model/generic_data_class.py
GeorgianBadita/remote-coding-platform-manager-service
7770df14417f6ec7c5165c8bbb03cdcbe4c57130
[ "MIT" ]
null
null
null
remote-coding-platform-manager-service/model/generic_data_class.py
GeorgianBadita/remote-coding-platform-manager-service
7770df14417f6ec7c5165c8bbb03cdcbe4c57130
[ "MIT" ]
null
null
null
remote-coding-platform-manager-service/model/generic_data_class.py
GeorgianBadita/remote-coding-platform-manager-service
7770df14417f6ec7c5165c8bbb03cdcbe4c57130
[ "MIT" ]
null
null
null
import json from dataclasses import dataclass, asdict @dataclass class GenericDataClass: def to_json(self) -> str: return json.dumps(asdict(self))
17.888889
41
0.732919
20
161
5.85
0.7
0
0
0
0
0
0
0
0
0
0
0
0.186335
161
8
42
20.125
0.89313
0
0
0
0
0
0
0
0
0
0
0
0
1
0.166667
false
0
0.333333
0.166667
0.833333
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
1
0
0
0
4
22ef21c2f4aaf9cbc7e59d9fc601a39c213cd598
29
py
Python
custom_components/ruuvitag/__init__.py
p4sI/ruuvitag-sensor
5f512af0424a1714b3b5f5aa30a1c865de8b7631
[ "Apache-2.0" ]
12
2018-06-25T12:11:29.000Z
2020-08-20T15:57:12.000Z
custom_components/ruuvitag/__init__.py
p4sI/ruuvitag-sensor
5f512af0424a1714b3b5f5aa30a1c865de8b7631
[ "Apache-2.0" ]
4
2019-05-15T14:53:44.000Z
2020-08-02T18:03:39.000Z
custom_components/ruuvitag/__init__.py
p4sI/ruuvitag-sensor
5f512af0424a1714b3b5f5aa30a1c865de8b7631
[ "Apache-2.0" ]
6
2018-07-29T11:45:03.000Z
2020-07-06T17:29:02.000Z
"""The ruuvitag component."""
29
29
0.689655
3
29
6.666667
1
0
0
0
0
0
0
0
0
0
0
0
0.068966
29
1
29
29
0.740741
0.793103
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
fe1e83af4eb75754d2a3fea09bd05ff15240f75e
199
py
Python
gr-azure-software-radio/python/keyvault/__init__.py
pomeroy3/azure-software-radio
a336e5670483e1085cfa1d754c6917c9e4cc6aec
[ "MIT" ]
null
null
null
gr-azure-software-radio/python/keyvault/__init__.py
pomeroy3/azure-software-radio
a336e5670483e1085cfa1d754c6917c9e4cc6aec
[ "MIT" ]
null
null
null
gr-azure-software-radio/python/keyvault/__init__.py
pomeroy3/azure-software-radio
a336e5670483e1085cfa1d754c6917c9e4cc6aec
[ "MIT" ]
null
null
null
# Copyright (c) Microsoft Corporation. # Licensed under the GNU General Public License v3.0 or later. # See License.txt in the project root for license information. # from .keyvault import pull_key
28.428571
62
0.778894
30
199
5.133333
0.9
0
0
0
0
0
0
0
0
0
0
0.011976
0.160804
199
6
63
33.166667
0.91018
0.79397
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
a3cdd96c0b96a5cbe4bbb344f1213244a01727f9
294
py
Python
crypt0/base/ascii_binary.py
Crypto0/Crypt0Lib-V1
9ea367cd4467222542a88c45c0a92be78158cceb
[ "MIT" ]
2
2018-10-09T18:10:23.000Z
2018-10-09T18:56:21.000Z
crypt0/base/ascii_binary.py
Crypto0/Crypt0Lib-V1
9ea367cd4467222542a88c45c0a92be78158cceb
[ "MIT" ]
null
null
null
crypt0/base/ascii_binary.py
Crypto0/Crypt0Lib-V1
9ea367cd4467222542a88c45c0a92be78158cceb
[ "MIT" ]
null
null
null
import binascii def ascii_to_binary(ascii): def ascii_bin(text, encoding='utf-8', errors='surrogatepass'): bits = bin(int(binascii.hexlify(text.encode(encoding, errors)), 16))[2:] return bits.zfill(8 * ((len(bits) + 7) // 8)) binary = ascii_bin(ascii) return binary
36.75
80
0.656463
41
294
4.609756
0.560976
0.084656
0
0
0
0
0
0
0
0
0
0.029167
0.183673
294
7
81
42
0.758333
0
0
0
0
0
0.061224
0
0
0
0
0
0
1
0.285714
false
0.142857
0.142857
0
0.714286
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
1
0
0
1
0
0
4
a3e44c0d7851f58125677e65ee21b0fead149570
299
py
Python
lawgokr/exceptions.py
ganadara135/law2
ea0edd54b6b626563e741619be5ae93ba6b61523
[ "MIT" ]
null
null
null
lawgokr/exceptions.py
ganadara135/law2
ea0edd54b6b626563e741619be5ae93ba6b61523
[ "MIT" ]
null
null
null
lawgokr/exceptions.py
ganadara135/law2
ea0edd54b6b626563e741619be5ae93ba6b61523
[ "MIT" ]
null
null
null
class Error(Exception): """Base class for other exceptions""" def __init__(self, message): self.message = message super().__init__(self.message) def __str__(self): return self.message class ElasticSearchError(Error): """Raised when elasticsearch error"""
21.357143
41
0.658863
32
299
5.78125
0.5625
0.237838
0.162162
0
0
0
0
0
0
0
0
0
0.227425
299
13
42
23
0.800866
0.210702
0
0
0
0
0
0
0
0
0
0
0
1
0.285714
false
0
0
0.142857
0.714286
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
1
0
0
4
4304fb812451f570d153a06d34052f2a9b7f7feb
1,456
py
Python
servo/data/fennel_rev0.py
neverware-mirrors/hdctools
dd7f911bb9051e615af7fcb71d921bd481f934fb
[ "BSD-3-Clause" ]
null
null
null
servo/data/fennel_rev0.py
neverware-mirrors/hdctools
dd7f911bb9051e615af7fcb71d921bd481f934fb
[ "BSD-3-Clause" ]
null
null
null
servo/data/fennel_rev0.py
neverware-mirrors/hdctools
dd7f911bb9051e615af7fcb71d921bd481f934fb
[ "BSD-3-Clause" ]
null
null
null
# Copyright 2020 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # generates fennel_rev0 revs = [0] inas = [ ('ina3221', '0x40:0', 'ppvar_sys', 7.7, 0.020, 'rem', True), # R91200 ('ina3221', '0x40:1', 'vbat', 7.7, 0.020, 'rem', True), # R90819 ('ina3221', '0x40:2', 'pp1800_h1', 1.8, 0.050, 'rem', True), # R90364 ('ina3221', '0x41:0', 'ppvar_bl', 7.7, 0.100, 'rem', True), # R391 ('ina3221', '0x41:1', 'pp1800_ec', 1.8, 0.050, 'rem', True), # R90366 ('ina3221', '0x41:2', 'pp3300_ctp', 3.3, 0.020, 'rem', True), # R90475 ('ina3221', '0x42:0', 'pp3300_h1', 3.3, 0.050, 'rem', True), # R90365 ('ina3221', '0x42:1', 'pp3300_wlan', 3.3, 0.020, 'rem', True), # R91136 ('ina3221', '0x42:2', 'pp1800_wlan', 1.8, 0.020, 'rem', True), # R91139 ('ina3221', '0x43:0', 'pp3300_lcm', 3.3, 0.020, 'rem', True), # R90518 ('ina3221', '0x43:1', 'pp5000_dram', 5.0, 0.020, 'rem', True), # R90649 ('ina3221', '0x43:2', 'pp5000_pmic', 5.0, 0.020, 'rem', True), # R90558 ('ina219', '0x44', 'pp3300_a', 3.3, 0.020, 'rem', True), # R90678 ('ina219', '0x45', 'ppvar_usb_c0_vbus', 20.0, 0.020, 'rem', True), # R90538 ('ina219', '0x46', 'pp1800_a', 1.8, 0.020, 'rem', True), # R90672 ]
58.24
82
0.521291
213
1,456
3.483568
0.403756
0.141509
0.103774
0.163073
0.226415
0.210243
0
0
0
0
0
0.305069
0.254808
1,456
24
83
60.666667
0.378802
0.194368
0
0
1
0
0.326106
0
0
0
0.052038
0
0
1
0
false
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
431413bb97086e81edf5eed93f85b4989313f106
4,611
py
Python
Aula28 17-12 Exercicios_open/exercicios/exercicio3.py
Renanrbsc/PadawanPython
6dc06a502d59127d0f180847e19b40c581baddd0
[ "MIT" ]
null
null
null
Aula28 17-12 Exercicios_open/exercicios/exercicio3.py
Renanrbsc/PadawanPython
6dc06a502d59127d0f180847e19b40c581baddd0
[ "MIT" ]
null
null
null
Aula28 17-12 Exercicios_open/exercicios/exercicio3.py
Renanrbsc/PadawanPython
6dc06a502d59127d0f180847e19b40c581baddd0
[ "MIT" ]
null
null
null
# Aula 28 - 17-12-2019 # Revisão de listas # Faça uma função que receba a lista como parametro e retorne uma # string em que cada linha seja uma pessoa. lista = [['1', 'Arnaldo', '23', 'm', 'alexcabeludo2@hotmail.com', '014908648117'], ['2', 'Haroldo', '44', 'f', 'baratarebelde@gmail.com', '050923172729'], ['3', 'Pilar', '50', 'm', 'wanderson10sp@gmail.com', '018937341049'], ['4', 'Suzete Salvador', '45', 'f', 'eladiomp2@yahoo.com.br', '056928409823'], ['5', 'Riane', '37', 'f', 'orkutzimpower@terra.com.br', '018916004377'], ['6', 'Waldir', '34', 'f', 'nandah.s2@bol.com.br', '058903756441'], ['7', 'Lilian', '22', 'f', 'arydoido@gmail.com', '031958621596'], ['8', 'Matilde', '20', 'm', 'eu_kaka_@hotmail.com', '012941959390'], ['9', 'Samanta', '19', 'm', 'carro.tuning@yahoo.com.br', '028964480437'], ['10', 'Margarida', '30', 'm', 'paraaconta.08@hotmail.com', '047903547580'], ['11', 'Evelyn', '31', 'm', 'joaosilvaticudo@gmail.com', '053958638386'], ['12', 'Alessio', '29', 'm', 'w.nill02@gmail.com', '033961294774'], ['13', 'Yolanda', '25', 'm', 'patty_karen2005@hotmail.com', '027903312626'], ['14', 'Germana', '33', 'f', 'jarlinhatopdelinhagv@hotmail.com', '053964603415'], ['15', 'Helio', '33', 'f', 'juh.slim@gmail.com', '046997316461'], ['16', 'Liége', '21', 'f', 'gledsonlds@hotmail.com', '056992948431'], ['17', 'Yan', '42', 'm', 'lucapratto@yahoo.com.br', '016963562866'], ['18', 'Silvain', '50', 'f', 'hie.s2@hotmail.com', '021963399433'], ['19', 'Brian', '33', 'f', 'juliagabrielle06@hotmail.com', '027962676732'], ['20', 'Deoclides', '40', 'f', 'patriciamascena@gmail.com', '012961047979'], ['21', 'Jaqueline', '32', 'm', 'aninha183@hotmail.com', '014958997782'], ['22', 'Rosamaria', '45', 'f', 'j_leosao@hotmail.com', '026944672627'], ['23', 'Carla', '42', 'm', 'jhasdfjo@hotmail.com', '046976625208'], ['24', 'Aida Santos', '30', 'f', 'nayara.cristinap@hotmail.com', '034920819199'], ['25', 'Thomas', '19', 'm', 'jfdslinda@bol.com.br', '030974027667'], ['26', 'Naiara', '23', 'm', 'darknees_666@ig.com.br', '018976696717'], ['27', 'Karyne', '17', 'm', 'garotosonhador_1@hotmail.com', '054984689319'], ['28', 'Alenis Dias', '43', 'f', 'vi_vi_cristinaf@hotmail.com', '034980886309'], ['29', 'Grace', '38', 'm', 'amandakell@uol.com.br', '041932906720'], ['30', 'Zacarias', '31', 'm', 'loca.som@hotmail.com', '041926007066'], ['31', 'Marco', '29', 'f', 'tashaqn@hotmail.com', '050919604868'], ['32', 'Angélica', '43', 'f', 'andrea_fatima2005@hotmail.com', '031984219049'], ['33', 'Dionisio', '38', 'f', 'tico_axe@yahoo.com.br', '029971421524'], ['34', 'Cassio', '23', 'm', 'blu.william@gmail.com', '052974708463'], ['35', 'Selma', '17', 'f', 'reinaldobeltrao@bol.com.br', '051974848498'], ['36', 'Flávia', '21', 'm', 'let_araujo23@yahoo.com.br', '033918718514'], ['37', 'Osni', '34', 'm', 'ash_highschool@hotmail.com', '046975591151'], ['38', 'Timoteo', '30', 'f', 'marcellaparaty@hotmail.com', '040927395638'], ['39', 'Cristiane', '38', 'm', 'lilimil125@yahoo.com.br', '054918308625'], ['40', 'Else', '45', 'm', 'laurinho_simoes@hotmail.com', '042908347369'], ['41', 'Cecília', '46', 'm', 'dani_sk8_95@hotmail.com', '025963481920'], ['42', 'Giulliane', '25', 'm', 'skarletlinda@hotmail.com', '027905662731'], ['43', 'Feliciano', '44', 'm', 'karinafloroliveira@hotmail.com', '055985937562'], ['44', 'Cassiane', '41', 'm', 'tauanerbd@gmail.com', '025998359783'], ['45', 'Aléssia', '21', 'f', 'thayna_bitencourt@yahoo.com.br', '033950734254'], ['46', 'Josie', '32', 'm', 'marclei@pop.com.br', '033972950508'], ['47', 'Thayná', '42', 'm', 'caio167@hotmail.com', '028984798536'], ['48', 'Paola', '50', 'm', 'chel_bdl@hotmail.com', '024966119466'], ['49', 'Silvio', '45', 'm', 'laurim_crazyboy@hotmail.com', '033986392040'], ['50', 'Vanusa', '23', 'm', 'aline_gatinha_13@yahoo.com.br', '015938655596']] # 1) Crie uma função que receba como parametro a lista e retorne 1 lista em que a lista[0] possua todas as listas # de mulheres e a lista[1] possua todas as listas de homens. # 2) Após receber a lista da função, imprima na tela a quantidade de mulheres e de homens que tem nesta lista. def lista_generos(lista): lista_masc = [] lista_femi = [] lista_genero = [] for i in lista: if i[3] == 'm': lista_masc.append(i) else: lista_femi.append(i) lista_genero.append(lista_masc) lista_genero.append(lista_femi) return lista_genero generos = lista_generos(lista) print(f'Lista do genero Masculino: ') for i in generos[0]: print(f'- {i}') print(f'Lista do genero Feminino: ') for i in generos[1]: print(f'- {i}')
118.230769
3,662
0.621557
603
4,611
4.699834
0.484245
0.091743
0.028229
0.012703
0.028229
0
0
0
0
0
0
0.20819
0.115593
4,611
38
3,663
121.342105
0.486758
0.092171
0
0.1
0
0
0.579439
0.212078
0
0
0
0
0
1
0.05
false
0
0
0
0.1
0.2
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
4315bfb5b0332a8b80cf6bea60196db4210d582a
93
py
Python
tests/test_basket_pom.py
benavir/selenium
67374ad52a7dfcb72cbf973449819f59a8571577
[ "Apache-2.0" ]
null
null
null
tests/test_basket_pom.py
benavir/selenium
67374ad52a7dfcb72cbf973449819f59a8571577
[ "Apache-2.0" ]
null
null
null
tests/test_basket_pom.py
benavir/selenium
67374ad52a7dfcb72cbf973449819f59a8571577
[ "Apache-2.0" ]
null
null
null
def test_shopping_basket(app): app.add_item_in_basket() app.remove_all_from_basket()
23.25
32
0.774194
15
93
4.266667
0.733333
0.28125
0
0
0
0
0
0
0
0
0
0
0.129032
93
3
33
31
0.790123
0
0
0
0
0
0
0
0
0
0
0
0
1
0.333333
false
0
0
0
0.333333
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
4
431972cd33a7efae3750d0abbc1ceb54563025ae
142
py
Python
toy_template_engine/template.py
coldfog/toy_template_engine
d9518057d6e68ab19ba1893990c2831d2aaa79a9
[ "MIT" ]
null
null
null
toy_template_engine/template.py
coldfog/toy_template_engine
d9518057d6e68ab19ba1893990c2831d2aaa79a9
[ "MIT" ]
null
null
null
toy_template_engine/template.py
coldfog/toy_template_engine
d9518057d6e68ab19ba1893990c2831d2aaa79a9
[ "MIT" ]
null
null
null
__author__ = 'fengyuyao' class Template(object): def __init__(self, source): pass def render(self, **kwargs): pass
14.2
31
0.605634
15
142
5.2
0.8
0
0
0
0
0
0
0
0
0
0
0
0.28169
142
9
32
15.777778
0.764706
0
0
0.333333
0
0
0.06338
0
0
0
0
0
0
1
0.333333
false
0.333333
0
0
0.5
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
1
0
0
0
0
0
4
432e6f9831d89ac50db13ca423aff1cebe292919
123
py
Python
backend/app_Loyverse_connector.py
DomPolizzi/loyverse-woocomerce-api
5be15923ff7d90a69146fa26ff2bd1c620643edb
[ "MIT" ]
null
null
null
backend/app_Loyverse_connector.py
DomPolizzi/loyverse-woocomerce-api
5be15923ff7d90a69146fa26ff2bd1c620643edb
[ "MIT" ]
null
null
null
backend/app_Loyverse_connector.py
DomPolizzi/loyverse-woocomerce-api
5be15923ff7d90a69146fa26ff2bd1c620643edb
[ "MIT" ]
null
null
null
import os from auth.auth import Loytoken from loyverse import API # =================== # ROUTES # ===================
11.181818
30
0.495935
12
123
5.083333
0.666667
0
0
0
0
0
0
0
0
0
0
0
0.162602
123
10
31
12.3
0.592233
0.373984
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
4333a74007a20a359c0a58dab53a217195f6f56b
963
py
Python
satella/coding/concurrent/futures/call_in_future.py
piotrmaslanka/satella
bf4ba7a21ad2ac93a366442a2b4574dc5568b87e
[ "MIT" ]
12
2019-12-13T10:17:38.000Z
2022-01-05T09:01:36.000Z
satella/coding/concurrent/futures/call_in_future.py
piotrmaslanka/satella
bf4ba7a21ad2ac93a366442a2b4574dc5568b87e
[ "MIT" ]
26
2016-04-01T11:55:26.000Z
2021-12-30T17:03:59.000Z
satella/coding/concurrent/futures/call_in_future.py
piotrmaslanka/satella
bf4ba7a21ad2ac93a366442a2b4574dc5568b87e
[ "MIT" ]
1
2021-05-31T08:45:22.000Z
2021-05-31T08:45:22.000Z
import typing as tp from concurrent.futures import Executor from satella.coding.concurrent.futures.futures import wrap_if def call_in_future(executor: Executor, function: tp.Callable, *args, **kwargs) -> tp.Callable[[], 'Future']: """ Return a callable, whose calling will schedule function to be executed on a target Executor. The returned function will accept any number of arguments and keyword arguments, but will simply ignore them. :param executor: executor to run at :param function: callable to schedule :param args: arguments to provide to the callable :param kwargs: keyword arguments to provide to the callable :return: a callable, calling which will schedule function to run at executor. Calling this callable will return the Future for that function """ def inner(*my_args, **my_kwargs): return wrap_if(executor.submit(function, *args, **kwargs)) return inner
35.666667
103
0.718588
130
963
5.276923
0.423077
0.049563
0.043732
0.06414
0.090379
0.090379
0
0
0
0
0
0
0.212876
963
26
104
37.038462
0.905013
0.553479
0
0
0
0
0.015707
0
0
0
0
0
0
1
0.25
false
0
0.375
0.125
0.875
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
1
1
1
0
0
4
4a2dfe78bdae5238563264d6186349a2e419a4b9
981
py
Python
setup.py
ananth-she11z/vTotalAPI
f04823a136642de6f280f1c57645ad7c13484c09
[ "MIT" ]
3
2020-08-04T05:17:03.000Z
2021-01-25T01:31:04.000Z
setup.py
ananth-she11z/vTotalAPI
f04823a136642de6f280f1c57645ad7c13484c09
[ "MIT" ]
null
null
null
setup.py
ananth-she11z/vTotalAPI
f04823a136642de6f280f1c57645ad7c13484c09
[ "MIT" ]
null
null
null
from distutils.core import setup setup( name = 'vTotalAPI', packages = ['vTotalAPI'], version = '11.0', license='MIT', description = 'Virustotal API v2 python module for automation', author = 'Ananth Gottimukala', author_email = 'ananth.venk88@gmail.com', url = 'https://github.com/ananth-she11z/vTotalAPI', download_url = 'https://github.com/ananth-she11z/vTotalAPI/archive/11.0.tar.gz', keywords = ['Virustotal', 'APIv2', 'Automation', 'API'], install_requires=[ 'requests >= 2.22.0', ], classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'Topic :: Software Development :: Build Tools', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.8', ], )
32.7
83
0.620795
105
981
5.771429
0.6
0.156766
0.206271
0.214521
0.125413
0.125413
0.125413
0
0
0
0
0.036506
0.218145
981
29
84
33.827586
0.753585
0
0
0.074074
0
0.037037
0.619348
0.024185
0
0
0
0
0
1
0
true
0
0.037037
0
0.037037
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
4a8ed77bed047731261f011279162d791eb50838
172
py
Python
nanto/nantonone.py
mmore500/nanto
dacc834205a2f0a9c6104435c34d89f902915603
[ "MIT" ]
null
null
null
nanto/nantonone.py
mmore500/nanto
dacc834205a2f0a9c6104435c34d89f902915603
[ "MIT" ]
null
null
null
nanto/nantonone.py
mmore500/nanto
dacc834205a2f0a9c6104435c34d89f902915603
[ "MIT" ]
null
null
null
import typing from .nanto import nanto def nantonone(value: typing.Any) -> typing.Any: """Replace value with None if value is NaN.""" return nanto(value, None)
17.2
50
0.69186
25
172
4.76
0.6
0.151261
0
0
0
0
0
0
0
0
0
0
0.197674
172
9
51
19.111111
0.862319
0.232558
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.5
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
1
0
0
0
0
4
4355ee9515117471da612da6dd19f8935747169f
423
py
Python
cxs/app/helpers/lib_vq.py
ajvazquez/CXS338
fca77807073f75670f2e7a99011dc198cc7c9829
[ "MIT" ]
1
2021-11-05T02:38:45.000Z
2021-11-05T02:38:45.000Z
cxs/app/helpers/lib_vq.py
ajvazquez/CXS338
fca77807073f75670f2e7a99011dc198cc7c9829
[ "MIT" ]
null
null
null
cxs/app/helpers/lib_vq.py
ajvazquez/CXS338
fca77807073f75670f2e7a99011dc198cc7c9829
[ "MIT" ]
null
null
null
""" Placeholders for missing VQ dependencies. """ C_INI_MEDIA_C_CODECS = None dictc01bit = {} v1_quant = None v2_quant = None v_codecs = None v_bits_sample = None def encode_vq(*args, **kwargs): return None def get_codebook_from_serial(*args, **kwargs): return None def get_vq_decoded_samples(*args, **kwargs): return None def get_group_of_serialized_codebooks_noencoding(*args, **kwargs): return None
18.391304
66
0.742317
61
423
4.803279
0.540984
0.095563
0.21843
0.273038
0.266212
0.266212
0
0
0
0
0
0.011204
0.156028
423
22
67
19.227273
0.809524
0.096927
0
0.285714
0
0
0
0
0
0
0
0
0
1
0.285714
false
0
0
0.285714
0.571429
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
4
437c025330fa7e8ebece2d14571839033b8bee16
35
py
Python
pymgit/__init__.py
watsonb/pymgit
974309821146349a8e72b4525b2319d4f7bc7139
[ "MIT" ]
1
2019-02-28T14:30:47.000Z
2019-02-28T14:30:47.000Z
pymgit/__init__.py
watsonb/pymgit
974309821146349a8e72b4525b2319d4f7bc7139
[ "MIT" ]
null
null
null
pymgit/__init__.py
watsonb/pymgit
974309821146349a8e72b4525b2319d4f7bc7139
[ "MIT" ]
null
null
null
# __init__.py __version__ = '0.6.0'
17.5
21
0.685714
6
35
2.666667
0.833333
0
0
0
0
0
0
0
0
0
0
0.096774
0.114286
35
2
21
17.5
0.419355
0.314286
0
0
0
0
0.217391
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
43815804191ec6ef2d16634f2b9d5ab8116771e5
167
py
Python
messengerbotenv/bin/django-admin.py
hakanmhmd/messenger_bot
e837ff980e6773ce2a86d6dc51e08c0e42a1c429
[ "MIT" ]
null
null
null
messengerbotenv/bin/django-admin.py
hakanmhmd/messenger_bot
e837ff980e6773ce2a86d6dc51e08c0e42a1c429
[ "MIT" ]
null
null
null
messengerbotenv/bin/django-admin.py
hakanmhmd/messenger_bot
e837ff980e6773ce2a86d6dc51e08c0e42a1c429
[ "MIT" ]
null
null
null
#!/Users/hakanmehmed/Desktop/recipe_bot/recipebot/bin/python from django.core import management if __name__ == "__main__": management.execute_from_command_line()
27.833333
60
0.802395
21
167
5.809524
0.904762
0
0
0
0
0
0
0
0
0
0
0
0.08982
167
5
61
33.4
0.802632
0.353293
0
0
0
0
0.074766
0
0
0
0
0
0
1
0
true
0
0.333333
0
0.333333
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
43ac73dc636e841db52cc21df07a626312391d17
22
py
Python
example_snippets/multimenus_snippets/Snippets/SciPy/Special functions/Statistical Functions (see also scipy.stats)/bdtrc Binomial distribution survival function.py
kuanpern/jupyterlab-snippets-multimenus
477f51cfdbad7409eab45abe53cf774cd70f380c
[ "BSD-3-Clause" ]
null
null
null
example_snippets/multimenus_snippets/Snippets/SciPy/Special functions/Statistical Functions (see also scipy.stats)/bdtrc Binomial distribution survival function.py
kuanpern/jupyterlab-snippets-multimenus
477f51cfdbad7409eab45abe53cf774cd70f380c
[ "BSD-3-Clause" ]
null
null
null
example_snippets/multimenus_snippets/Snippets/SciPy/Special functions/Statistical Functions (see also scipy.stats)/bdtrc Binomial distribution survival function.py
kuanpern/jupyterlab-snippets-multimenus
477f51cfdbad7409eab45abe53cf774cd70f380c
[ "BSD-3-Clause" ]
1
2021-02-04T04:51:48.000Z
2021-02-04T04:51:48.000Z
special.bdtrc(k, n, p)
22
22
0.681818
5
22
3
1
0
0
0
0
0
0
0
0
0
0
0
0.090909
22
1
22
22
0.75
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
43b4e7611921ce122ff5734b5f109efcd91026aa
364,217
py
Python
newtests/010322_sony.py
mark-nick-o/mavlink_experiments
a9e6d4a87ef7c8e58ad36ece2533b3fecb39dbb1
[ "MIT" ]
null
null
null
newtests/010322_sony.py
mark-nick-o/mavlink_experiments
a9e6d4a87ef7c8e58ad36ece2533b3fecb39dbb1
[ "MIT" ]
null
null
null
newtests/010322_sony.py
mark-nick-o/mavlink_experiments
a9e6d4a87ef7c8e58ad36ece2533b3fecb39dbb1
[ "MIT" ]
null
null
null
# =============================================================================================================================== # # Name : mavlinkSonyCamWriteVals.py # Desc : Global memory value class for use to write mavlink to sony cam # Auth : AIR-obots Ai-Robots # # =============================================================================================================================== # # for paralel tasking of the camera action routines # # from multiprocessing import Process import multiprocessing # for debug import logging # for signal interypt handling import signal import time class fastGlobals: __slots__ = ('take_picture','start_video',) # __slots__ defines a fast variable take_picture: int start_video: int # ==== enumerated camera state class # import enum class camStateClass(enum.IntEnum): idle = 0 taking_photo = 1 photo_ack = 2 uploading_photo = 3 photo_complete = 4 recording_vid = 5 video_ack = 6 uploading_vid = 7 video_complete = 8 configuring_photo = 9 configuring_video = 10 photo_continuos = 11 class mavlinkSonyCamWriteVals(): # state for multi-process object STATE_INIT = 99 STATE_READY = 1 STATE_CAM_WRITING = 2 STATE_MAV_READING = 3 STATE_MAV_WRITING = 4 STATE_CAM_READING = 5 # global counter for values numberOfVals = 8 # flags to incdicate write action for previous store register WRITE_PREV_DATA = 1 DONT_WRITE_PREV_DATA = 0 # mavlink write actions (requests from GCS) MAV_REQ_ALL_PARAM = 255 ParamStillCap = 1 ParamWhiteBala = 2 ParamShutSpd = 4 ParamIso = 8 ParamFocus = 16 ParamFocusArea = 32 ParamAperture = 64 ParamExPro = 128 # indiviual states when a sequential priority queue is required FUNC_IDLE = 0 FUNC_EX_PRO = 7 FUNC_APER = 8 FUNC_FOCUS = 9 FUNC_ISO = 10 FUNC_SS = 11 FUNC_WB = 12 FUNC_SC = 13 # bit numbers representing the write protect status for each feature # true is write_protect state on # WriPro_EX_PRO = 1 WriPro_APER = 2 WriPro_FOCUS = 3 WriPro_ISO = 4 WriPro_SS = 5 WriPro_WB = 6 WriPro_SC = 7 WriPro_FOCUSA = 8 def __init__ (self): self.set_sony_iso = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_aperture = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_ex_pro = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_focus_area = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_focus = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_shutter = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_white_bal = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.set_sony_still_cap_mode = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_iso = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_aperture = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_ex_pro = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_focus_area = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_focus = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_shutter = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_white_bal = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.prev_sony_still_cap_mode = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.mav_req_all_param = multiprocessing.Value('i', 0) self.mav_ext_req_all_param = multiprocessing.Value('i', 0) self.mav_write_pro_word = multiprocessing.Value('l', 0) self.take_photo = multiprocessing.Value('b', False) self.take_continuos = multiprocessing.Value('b', False) self.reset_cam = multiprocessing.Value('b', False) self.state = multiprocessing.Value('i', mavlinkSonyCamWriteVals.STATE_INIT) self.mp_state = multiprocessing.Value('i', mavlinkSonyCamWriteVals.FUNC_IDLE) mavlinkSonyCamWriteVals.numberOfVals += 8 # global counter of the number of values def __del__(self): class_name = self.__class__.__name__ mavlinkSonyCamWriteVals.numberOfVals -= 1 # global counter of the number of values print('{} Deleted'.format(class_name)) def get_value_counter(self): print('mavlink to sony writes has %d set-points' % (mavlinkSonyCamWriteVals.numberOfVals)) return mavlinkSonyCamWriteVals.numberOfVals def init_class_state( self ): if (self.state.value == mavlinkSonyCamWriteVals.STATE_INIT): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY def set_WritePro(self, myId, bit, timeout=20, reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.mav_write_pro_word.get_lock(): self.mav_write_pro_word.value |= (1 << bit) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY print(f"\033[37m set the write protect word for {bit} \033[0m") return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clear_WritePro(self, myId, bit, timeout=20, reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.mav_write_pro_word.get_lock(): self.mav_write_pro_word.value &= ~(1 << bit) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY print(f"\033[37m cleared the write protect word for {bit} \033[0m") return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def setVal_sony_iso(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.prev_sony_iso.get_lock(): self.prev_sony_iso.value = self.set_sony_iso.value with self.set_sony_iso.get_lock(): self.set_sony_iso.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY print(f"\033[37m wrote the value {value} to {self.prev_sony_iso.value} {self.set_sony_iso.value} \033[0m") #exit(99) return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY #exit(90) return False def clearReq_sony_iso(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_iso.get_lock(): self.set_sony_iso.value = self.prev_sony_iso.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY print(f"\033[37m Reset the sony Iso request its not writable \033[0m") return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_iso(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print(' value: {} previous: {}'.format(self.set_sony_iso.value,self.prev_sony_iso.value)) c = self.set_sony_iso.value p = self.prev_sony_iso.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_iso.value,self.prev_sony_iso.value,False def setVal_sony_aperture(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.prev_sony_aperture.get_lock(): self.prev_sony_aperture.value= self.set_sony_aperture.value with self.set_sony_aperture.get_lock(): self.set_sony_aperture.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_aperture(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_aperture.get_lock(): self.set_sony_aperture.value = self.prev_sony_aperture.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_aperture(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print(' value: {} previous: {}'.format(self.set_sony_aperture.value,self.prev_sony_aperture.value)) c = self.set_sony_aperture.value p = self.prev_sony_aperture.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_aperture.value,self.prev_sony_aperture.value,False def setVal_sony_ex_pro(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.set_sony_ex_pro.get_lock(): self.prev_sony_ex_pro.value = self.set_sony_ex_pro.value with self.set_sony_ex_pro.get_lock(): self.set_sony_ex_pro.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_ex_pro(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_ex_pro.get_lock(): self.set_sony_ex_pro.value = self.prev_sony_ex_pro.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_ex_pro(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print(' value: {} previous: {}'.format(self.set_sony_ex_pro.value,self.prev_sony_ex_pro.value)) c = self.set_sony_ex_pro.value p = self.prev_sony_ex_pro.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_ex_pro.value,self.prev_sony_ex_pro.value,False def setVal_sony_focus_area(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.prev_sony_focus_area.get_lock(): self.prev_sony_focus_area.value = self.set_sony_focus_area.value with self.set_sony_focus_area.get_lock(): self.set_sony_focus_area.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_focus_area(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_focus_area.get_lock(): self.set_sony_focus_area.value = self.prev_sony_focus_area.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_focus_area(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print(' value: {} previous: {}'.format(self.set_sony_focus_area.value,self.prev_sony_focus_area.value)) c = self.set_sony_focus_area.value p = self.prev_sony_focus_area.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_focus_area.value,self.prev_sony_focus_area.value,False def setVal_sony_focus(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.prev_sony_focus.get_lock(): self.prev_sony_focus.value = self.set_sony_focus.value with self.set_sony_focus.get_lock(): self.set_sony_focus.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_focus(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_focus.get_lock(): self.set_sony_focus.value = self.prev_sony_focus.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_focus(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print(' value: {} previous: {}'.format(self.set_sony_focus.value,self.prev_sony_focus.value)) c = self.set_sony_focus.value p = self.prev_sony_focus.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_focus.value,self.prev_sony_focus.value,False def setVal_sony_shutter(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.prev_sony_shutter.get_lock(): self.prev_sony_shutter.value = self.set_sony_shutter.value with self.set_sony_shutter.get_lock(): self.set_sony_shutter.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_shutter(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_shutter.get_lock(): self.set_sony_shutter.value = self.prev_sony_shutter.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_shutter(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print('value: {} previous: {}'.format(self.set_sony_shutter.value,self.prev_sony_shutter.value)) c = self.set_sony_shutter.value p = self.prev_sony_shutter.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_shutter.value,self.prev_sony_shutter.value,False def setVal_sony_white_bal(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.set_sony_white_bal.get_lock(): self.prev_sony_white_bal.value = self.set_sony_white_bal.value with self.set_sony_white_bal.get_lock(): self.set_sony_white_bal.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_white_bal(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_white_bal.get_lock(): self.set_sony_white_bal.value = self.prev_sony_white_bal.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_white_bal(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print('value: {} previous: {}'.format(self.set_sony_white_bal.value,self.prev_sony_white_bal.value)) c = self.set_sony_white_bal.value p = self.prev_sony_white_bal.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_white_bal.value,self.prev_sony_white_bal.value,False def setVal_sony_still_cap_mode(self,value,myId,mode=0,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId if mode == 1: with self.set_sony_still_cap_mode.get_lock(): self.prev_sony_still_cap_mode.value = self.set_sony_still_cap_mode.value with self.set_sony_still_cap_mode.get_lock(): self.set_sony_still_cap_mode.value = int(value) with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def clearReq_sony_still_cap_mode(self,myId,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.set_sony_still_cap_mode.get_lock(): self.set_sony_still_cap_mode.value = self.prev_sony_still_cap_mode.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return False def getVal_sony_still_cap_mode(self,YourID,timeout=20,reset_state=False): timeCnt = 0 while (not (self.state.value == mavlinkSonyCamWriteVals.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print('value: {} previous: {}'.format(self.set_sony_still_cap_mode.value,self.prev_sony_still_cap_mode.value)) c = self.set_sony_still_cap_mode.value p = self.prev_sony_still_cap_mode.value with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return c,p,True else: if (reset_state == True): with self.state.get_lock(): self.state.value = mavlinkSonyCamWriteVals.STATE_READY return self.set_sony_still_cap_mode.value,self.prev_sony_still_cap_mode.value,False def setMavIsoModeData( self, dataRcv ): ret = False ret = self.setVal_sony_iso(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavIsoModeData( self ): ret = False set_sony_iso = 0 prev_sony_iso = 0 set_sony_iso,prev_sony_iso,ret = self.getVal_sony_iso(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony_iso,prev_sony_iso,ret def setMavApertureData( self, dataRcv ): ret = False ret = self.setVal_sony_aperture(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavApertureData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_aperture(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret def setMavExProData( self, dataRcv ): ret = False ret = self.setVal_sony_ex_pro(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavExProData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_ex_pro(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret def setMavFocusAreaData( self, dataRcv ): ret = False ret = self.setVal_sony_focus_area(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavFocusAreaData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_focus_area(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret def setMavFocusData( self, dataRcv ): ret = False ret = self.setVal_sony_focus(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavFocusData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_focus(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret def setMavShutterData( self, dataRcv ): ret = False ret = self.setVal_sony_shutter(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavShutterData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_shutter(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret def setMavWhiteBalData( self, dataRcv ): ret = False ret = self.setVal_sony_white_bal(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavWhiteBalData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_white_bal(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret def setMavStillCapModeData( self, dataRcv ): ret = False ret = self.setVal_sony_still_cap_mode(dataRcv,mavlinkSonyCamWriteVals.STATE_MAV_WRITING,mavlinkSonyCamWriteVals.DONT_WRITE_PREV_DATA,5) return ret def getMavStillCapModeData( self ): ret = False set_sony = 0 prev_sony = 0 set_sony,prev_sony,ret = self.getVal_sony_still_cap_mode(mavlinkSonyCamWriteVals.STATE_MAV_READING) return set_sony,prev_sony,ret # =============================================================================================================================== # # Name : MemoryValueClass.py # Desc : Global memory value class for use with cameras and mavlink # Auth : AIR-obots Ai-Robots # # =============================================================================================================================== import time class memoryValue(): # multi process thread status of object STATE_READY = 1 STATE_CAM_WRITING = 2 STATE_MAV_READING = 3 STATE_MAV_WRITING = 4 STATE_CAM_READING = 5 # number of objects created numberOfVals = 0 def __init__ (self, name = 'value_name_not_set', signal = 0, prev = 0, state = STATE_READY): self.signal = multiprocessing.Value('i', signal) # signal.value value self.prev = multiprocessing.Value('i', prev) # previous signal value self.state = multiprocessing.Value('i', state) # state of the value self.nextpointer = None # pointer for chain if needed self.name = name # name as a string self.timestamp = multiprocessing.Value('l', 0) # timestamp self.updateNeeded = multiprocessing.Value('b', False) # update required self.ack_send = multiprocessing.Value('b', False) # param_ext_ack needed self.index = 0 # index number used for ack send memoryValue.numberOfVals += 1 # global counter of the number of values def __del__(self): class_name = self.__class__.__name__ memoryValue.numberOfVals -= 1 # global counter of the number of values print('{} Deleted'.format(class_name)) def get_value_counter(self): print('%s: %d' % (self.name,memoryValue.numberOfVals)) return memoryValue.numberOfVals def get_value_data(self,YourID,timeout=100): timeCnt = 0 while (not (self.state.value == memoryValue.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = YourID print('Description: {}. value: {} previous: {}'.format(self.name, self.signal.value,self.prev.value)) with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return self.name,self.signal.value,self.prev.value,True else: return self.name,self.signal.value,self.prev.value,False def set_value(self,value,myId,timeout=100): timeCnt = 0 while (not (self.state.value == memoryValue.STATE_READY)) and (timeCnt < timeout): time.sleep(0.1) timeCnt += 1 if (timeCnt < timeout): with self.state.get_lock(): self.state.value = myId with self.prev.get_lock(): self.prev.value = self.signal.value with self.signal.get_lock(): self.signal.value = value with self.updateNeeded.get_lock(): self.updateNeeded.value = True with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return True else: return False def get_value_data_if_avail(self,YourID): if (self.state.value == memoryValue.STATE_READY): with self.state.get_lock(): self.state.value = YourID print('Description: {}. value: {}'.format(self.name, self.signal.value)) with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return self.name,self.signal.value,self.prev.value,True else: return self.name,self.signal.value,self.prev.value,False def set_update_flag( self, stateSent, myId ): if (self.state.value == memoryValue.STATE_READY): with self.state.get_lock(): self.state.value = myId with self.state.get_lock(): self.updateNeeded.value = stateSent with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return True else: return False def get_update_flag( self, myId ): v = 0 if (self.state.value == memoryValue.STATE_READY): with self.state.get_lock(): self.state.value = myId v = self.updateNeeded.value with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return v,True else: return v,False def set_ack_send( self, stateSent, myId ): if (self.state.value == memoryValue.STATE_READY): with self.state.get_lock(): self.state.value = myId with self.ack_send.get_lock(): self.ack_send.value = stateSent with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return True else: return False def get_ack_send( self, myId ): v = 0 if (self.state.value == memoryValue.STATE_READY): with self.state.get_lock(): self.state.value = myId v = self.ack_send.value with self.state.get_lock(): self.state.value = memoryValue.STATE_READY return v,True else: return v,False if __name__ == '__main__': # # Test the library is okay # initVal = 23 getName = "noName" getValueforMAVSending = 0 getPrev = 0 SonyWhiteBalance = memoryValue('sonyWhiteBal',initVal) FocusSetpoint = memoryValue('FocusSetpoint',initVal+6) # # example using in mavlink sender # mavSetPointVal = 99 #we_got_from_mavlink Timeout = 20 if (FocusSetpoint.set_value(mavSetPointVal, memoryValue.STATE_MAV_WRITING, Timeout) == True): # { value has been successfully set } print("set the setpoint value focus") # # example to get the white balance setting from the cam to send over mavlink # getName, getValueforMAVSending, getPrev, myState = SonyWhiteBalance.get_value_data(memoryValue.STATE_MAV_READING, Timeout) if (myState == True): # now pack tha data print("got data ok") else: # you got an error or timeout print("data error") # # example using in mavlink sender # mavSetPointVal = 199 #we_got_from_mavlink Timeout = 20 if (SonyWhiteBalance.set_value(mavSetPointVal, memoryValue.STATE_MAV_WRITING, Timeout) == True): # { value has been successfully set } print("set the setpoint value white balance") # # example to get the white balance setting from the cam to send over mavlink # getName, getValueforMAVSending, getPrev, myState = SonyWhiteBalance.get_value_data(memoryValue.STATE_MAV_READING, Timeout) if (myState == True): # now pack tha data print("got data ok") else: # you got an error or timeout print("data error") # # example to iterate without waiting for completion on the write to the value from elsewhere # myState = False while not myState == True: getName, getVal, getPrev, myState = FocusSetpoint.get_value_data_if_avail( memoryValue.STATE_CAM_READING ) if myState == True: # now use this value and send to the camera print("setpoint available") else: # do something else while watiting print("setpoint being written by other task") # what you do until it has arrived time.sleep(0.1) # what you do after print("using the setpoint to change the camera") # # print the number of memory values # print(FocusSetpoint.get_value_counter()) print(SonyWhiteBalance.get_value_counter()) # # Release the shared memory # del FocusSetpoint del SonyWhiteBalance # =============================================================================================================================== # # Name : NewSonyAlphaClass.py # Desc : Communicate with new Sony Alpha Series of Camera # Auth : AIR-obots Ai-Robots # # =============================================================================================================================== import shlex, subprocess, pprint class sonyAlphaNewCamera(): def __init__ (self, name = 'sonyAlphaCamClass'): self.name = name # name as a string self.error_counts = multiprocessing.Value('i', 0) def __del__(self): class_name = self.__class__.__name__ print('{} Deleted'.format(class_name)) def check_my_os( self ): if ((sys.platform=='linux2') or (sys.platform=='linux')): return 1 elif sys.platform=='win32': return 2 else: return 3 def my_timestamp( self ): if (self.check_my_os() == 1): cmd = "date +%s" return( int(os.popen(cmd).read()) ) def take_a_picture_now( self,flag ): # run the API command in the shell and look for the descriptor for the field # if (flag == 1): cmd='/home/pi/cams/SonyTEST32/take_picture/RemoteCli ' c = os.popen(cmd) print(c.read()) flag = 2 # fastGlobals.take_picture = 2 print(f"\033[36m Took the picture {flag}") return 2 return flag def set_sony_iso_orig( self, isoVal ): # run the API command in the shell and look for the descriptor for the field # isoValArg=str(isoVal) cmd='/home/pi/cams/SonyTEST32/set_iso/RemoteCli ' + isoValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "ISO_Mode"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(f"{output} \n returned to shell {p2.returncode}") s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('ISO_Format') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_iso( self, isoVal ): # run the API command in the shell and look for the descriptor for the field # isoValArg=str(isoVal) cmd='/home/pi/cams/SonyTEST32/set_iso/RemoteCli ' + isoValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # alternative using file........ # # with open('out.txt','w+') as fout: # s=subprocess.call(args, stdout=fout) # fout.seek(0) # output=fout.read() # a = shlex.split(output) # fout.close() # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('ISO_Format') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_aperture_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_aperture/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Aperture_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Aperture_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_aperture( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_aperture/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('Aperture_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_ex_pro_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_ex_pro/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Exposure_Program_Value"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Exposure_Program_Value') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_ex_pro( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_ex_pro/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('Exposure_Program_Value') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_focus_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_focus/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Focus_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Focus_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_focus( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_focus/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('Focus_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_focus_area_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_fa/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Focus_Area_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Focus_Area_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_focus_area( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_fa/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('Focus_Area_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_shutter_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_shutter/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Shutter_Value"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string zz = z.replace("\"","") # get rid of the inch symbol it will crash us a = shlex.split(zz) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Shutter_Value') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_shutter( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_shutter/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string zz = z.replace("\"","") # get rid of the inch symbol it will crash us a = shlex.split(zz) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('Shutter_Value') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 print(answers) return answers def set_sony_white_bal_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_wb/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "White_Bal_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('White_Bal_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_white_bal( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_wb/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('White_Bal_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_still_cap_orig( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_still_cap/RemoteCli ' + ValArg args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Still_Capture_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Still_Capture_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def set_sony_still_cap( self, Val ): # run the API command in the shell and look for the descriptor for the field # ValArg=str(Val) cmd='/home/pi/cams/SonyTEST32/set_still_cap/RemoteCli ' + ValArg args = shlex.split(cmd) # CONSIDER :: because we have to trap various errors and act on them we had to parse the output for other things i might modify CameraDevice.cpp to # cover it all and exit as quick as possible using return codes but i couldnt succeed to read them all successfully using .returncode property # with the pipe attached as above and we dont want too many delays # s=subprocess.run( args, stdout=subprocess.PIPE ) output=s.stdout #s.stdout.close() z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] # new error handler sends a unique reply which means count these errors and then force a reset of the usb # if ( not(z.find("No cameras detected") == -1) or not(z.find("Failed to get") == -1)): self.error_counts.value += 1 print(f"\033[31m Error Reading from Camera USB Link {self.error_counts.value} \033[0m") return answers # look for the not writable option # if not(z.find("not writable") == -1): print("\033[31m This option is not writable \033[0m ") answers.append(-1) answers.append(-1) answers.append(0) answers.append("CAN_NOT_WRITE") return answers for xx in a: if xx.find('Still_Capture_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_still_cap_mode( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/still_cap_mode/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Still_Capture_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Still_Capture_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_white_balance( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/white_bal/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "White_Bal_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('White_Bal_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_ex_pro( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/exp_pro_mode/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Exposure_Program_Value"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Exposure_Program_Value') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_aperture( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/get_aperture/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Aperture_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Aperture_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_focus( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/get_focus/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Focus_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Focus_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_focus_area( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/get_focus_dist/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Focus_Area_Val"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Focus_Area_Val') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_iso( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/get_iso/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "ISO_Format"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string a = shlex.split(z) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('ISO_Format') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers def get_sony_shut_spd( self ): # run the API command in the shell and look for the descriptor for the field # cmd='/home/pi/cams/SonyTEST32/get_shutter/RemoteCli ' args = shlex.split(cmd) s=subprocess.Popen(args, stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "Shutter_Value"], stdin=s.stdout, stdout=subprocess.PIPE) # look for only this string in the output output = p2.communicate()[0] print(output) s.stdout.close() # consider if needed (if check of setval isnt working look for "cancelled" in the program output # # s=subprocess.Popen(args, stdout=subprocess.PIPE) # p3 = subprocess.Popen(["grep", "cancelled"], stdin=s.stdout, stdout=subprocess.PIPE) # output2 = p3.communicate()[0] z = output.decode('ascii') # convert bytes array output to ascii string zz = z.replace("\"","") # remove quoate mark meaning seconds a = shlex.split(zz) # split this unique output into fields separated by commas # # Using this parser as it sometimes missed the bracket at the start (odd??) in the popen output # we get the value fields before and after and return that list # itemNo = 0 idx = 99999 answers = [] for xx in a: if xx.find('Shutter_Value') > -1: idx = itemNo else: if (idx != 99999): if xx.find(':') > -1: idx = itemNo else: if not (xx.isdigit()): if xx.find("AUTO") > -1: xx = str(0) xx = xx.replace(",","") vv = xx.strip("}") # caters for a case in testing where i have closing bracket 34} answers.append(vv) idx = 99999 itemNo += 1 return answers # ======================= new additions to the class ================================================ def setSonyObjData( self, mem, camDataPointVal, Timeout = 100 ): if not (mem.set_value(camDataPointVal, mem.STATE_CAM_WRITING, Timeout) == True): print("\033[31m value has not been successfully set \033[0m") return False else: return True def initSonyCamExProData( self ): ans = self.get_sony_ex_pro( ) if not (ans is None): if (len(ans) > 0): print(f" Exposure Prog Mode = {ans}") try: SonyObject = memoryValue('S_EX_PRO_MODE',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_EX_PRO_MODE',0) else: print("\033[31m Failed get the camera ExPro \033[0m") SonyObject = memoryValue('S_EX_PRO_MODE',0) else: print("\033[31m Cant get Exposure Prog Mode \033[0m") SonyObject = memoryValue('S_EX_PRO_MODE',0) SonyObject.index = memoryValue.numberOfVals print(f"Expro : created object number : {SonyObject.index}") return SonyObject def getSonyCamExProData( self, mem ): ret = False ans = self.get_sony_ex_pro( ) if not (ans is None): if (len(ans) > 0): print(f" exposure program mode = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the exposure program mode\033[0m ") else: print("\033[31m Cant get Exposure Prog Mode \033[0m") return ret def initSonyApertureData( self ): ans = self.get_sony_aperture( ) if not (ans is None): if (len(ans) > 0): print(f" Aperture = {ans}") try: SonyObject = memoryValue('S_APERTURE',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_APERTURE',0) else: print("\033[31m Failed get the camera aperture \033[0m") SonyObject = memoryValue('S_APERTURE',0) else: print("\033[31m Cant get Aperture \033[0m") SonyObject = memoryValue('S_APERTURE',0) SonyObject.index = memoryValue.numberOfVals print(f"Aperture : created object number : {SonyObject.index}") return SonyObject def getSonyApertureData( self, mem ): ret = False ans = self.get_sony_aperture( ) if not (ans is None): if (len(ans) > 0): print(f" aperture = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the aperture \033[0m") else: print("\033[31m Cant get aperture \033[0m") return ret def initSonyCamFocusData( self ): ###### @@11 ans = self.get_sony_focus( ) if not (ans is None): if (len(ans) > 0): print(f" Focus Mode = {ans}") try: SonyObject = memoryValue('S_FOCUS_MODE',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_FOCUS_MODE',0) else: print("\033[31m Failed get the camera focus mode \033[0m") SonyObject = memoryValue('S_FOCUS_MODE',0) else: print("\033[31m Cant get Focus Mode \033[0m") SonyObject = memoryValue('S_FOCUS_MODE',0) SonyObject.index = memoryValue.numberOfVals print(f"FocusData : created object number : {SonyObject.index}") return SonyObject def getSonyCamFocusData( self, mem ): ret = False ans = self.get_sony_focus( ) if not (ans is None): if (len(ans) > 0): print(f" focus = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the focus mode object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the focus mode \033[0m") else: print("\033[31m Cant get focus mode \033[0m") return ret def initSonyCamFocusAreaData( self ): ans = self.get_sony_focus_area( ) if not (ans is None): if (len(ans) > 0): print(f" Focus Area = {ans}") try: SonyObject = memoryValue('S_FOCUS_AREA',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the focus area object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_FOCUS_AREA',0) else: print("\033[31m Failed get the camera focus area \033[0m") SonyObject = memoryValue('S_FOCUS_AREA',0) else: print("\033[31m Cant get Focus Mode \033[0m") SonyObject = memoryValue('S_FOCUS_AREA',0) SonyObject.index = memoryValue.numberOfVals print(f"Focus Area : created object number : {SonyObject.index}") return SonyObject def getSonyCamFocusAreaData( self, mem ): ret = False ans = self.get_sony_focus_area( ) if not (ans is None): if (len(ans) > 0): print(f"\033[33m FOCUS AREA = {ans} \033[0m") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the focus area object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the focus area \033[0m") else: print("\033[31m Cant get focus area ") return ret def initSonyCamISOData( self ): ans = self.get_sony_iso( ) if not (ans is None): if (len(ans) > 0): print(f" ISO = {ans}") try: SonyObject = memoryValue('S_ISO',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the iso object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_ISO',0) else: print("\033[31m Failed get the camera iso \033[0m") SonyObject = memoryValue('S_ISO',0) else: print("\033[31m Cant get ISO \033[0m") SonyObject = memoryValue('S_ISO',0) SonyObject.index = memoryValue.numberOfVals print(f"ISO : created object number : {SonyObject.index}") return SonyObject def getSonyCamISOData( self, mem ): ret = False ans = self.get_sony_iso( ) if not (ans is None): if (len(ans) > 0): print(f" ISO = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the iso object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the iso \033[0m") else: print("\033[31m Cant get iso \033[0m") return ret def initSonyCamShutSpdData( self ): ans = self.get_sony_shut_spd( ) if not (ans is None): if (len(ans) > 0): print(f" Shutter Speed = {ans}") try: SonyObject = memoryValue('S_SHUT_SPD',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the shut spd object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_SHUT_SPD',0) else: print("\033[31m Failed get the camera shutter speed \033[0m") SonyObject = memoryValue('S_SHUT_SPD',0) else: print("\033[31m Cant get Shutter Speed \033[0m") SonyObject = memoryValue('S_SHUT_SPD',0) SonyObject.index = memoryValue.numberOfVals print(f"Shut Speed : created object number : {SonyObject.index}") return SonyObject def getSonyCamShutSpdData( self, mem ): ret = False ans = self.get_sony_shut_spd( ) if not (ans is None): if (len(ans) > 0): print(f" Shutter Speed = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the shutter speed \033[0m") else: print("\033[31m Cant get shutter speed \033[0m") return ret def initSonyCamWhiteBalaData( self ): ans = self.get_sony_white_balance( ) if not (ans is None): if (len(ans) > 0): print(f" White Balance = {ans}") try: SonyObject = memoryValue('S_WHITE_BAL',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_WHITE_BAL',0) else: print("\033[31m Failed get the camera white balance \033[0m") SonyObject = memoryValue('S_WHITE_BAL',0) else: print("\033[31m Cant get Shutter Speed \033[0m") SonyObject = memoryValue('S_WHITE_BAL',0) SonyObject.index = memoryValue.numberOfVals print(f"White Balance : created object number : {SonyObject.index}") return SonyObject def getSonyCamWhiteBalaData( self, mem ): ret = False ans = self.get_sony_white_balance( ) if not (ans is None): if (len(ans) > 0): print(f" White Balance = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the white balance object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the camera white balance \033[0m") else: print("\033[31m Cant get white balance \033[0m") return ret def initSonyCamStillCapModeData( self ): ans = self.get_sony_still_cap_mode( ) if not (ans is None): if (len(ans) > 0): print(f" Still Cap Mode = {ans}") try: SonyObject = memoryValue('S_STILL_CAP',int(ans[0])) with SonyObject.updateNeeded.get_lock(): SonyObject.updateNeeded.value = True except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) SonyObject = memoryValue('S_STILL_CAP',0) else: print("\033[31m Failed get the camera still capture mode \033[0m") SonyObject = memoryValue('S_STILL_CAP',0) else: print("\033[31m Cant get Still Capture Mode \033[0m") SonyObject = memoryValue('S_STILL_CAP',0) SonyObject.index = memoryValue.numberOfVals print(f"Still Cap Mode : created object number : {SonyObject.index}") return SonyObject def getSonyCamStillCapModeData( self, mem ): ret = False ans = self.get_sony_still_cap_mode( ) if not (ans is None): if (len(ans) > 0): print(f" Still Cap Mode = {ans}") try: ret = self.setSonyObjData( mem, int(ans[0]) ) except Exception as err_msg: print("\033[31m Failed set the object to initial value : %s \033[0m" % (err_msg)) else: print("\033[31m Failed get the camera still capture mode \033[0m") else: print("\033[31m Cant get still cap mode \033[0m") return ret def enumerate_still_cap_sony_a7( self, num ): enum_num = 0 enum_num_state = True if num == 65543: enum_num = 2 elif num == 1: enum_num = 0 elif num == 65540: enum_num = 1 elif num == 65537: enum_num = 3 elif num == 65538: enum_num = 4 elif num == 196611: enum_num = 5 elif num == 196610: enum_num = 6 elif num == 196609: enum_num = 7 elif num == 524289: enum_num = 8 elif num == 524290: enum_num = 9 elif num == 524293: enum_num = 10 elif num == 524294: enum_num = 11 elif num == 524251: enum_num = 12 elif num == 524292: enum_num = 13 elif ((num >= 262913) and (num <= 262928)): enum_num = 14 + (num-262913) elif ((num >= 327681) and (num <= 327696)): enum_num = 30 + (num-327681) elif num == 393218: enum_num = 46 elif num == 393217: enum_num = 47 elif num == 458754: enum_num = 48 elif num == 458753: enum_num = 49 else: enum_num_state = False return enum_num_state, enum_num def enumerate_aperture_sony_a7( self, num ): enum_num = 0 enum_num_state = True if num == 280: enum_num = 0 elif num == 320: enum_num = 1 elif num == 350: enum_num = 2 elif num == 400: enum_num = 3 elif num == 450: enum_num = 4 elif num == 500: enum_num = 5 elif num == 560: enum_num = 6 elif num == 630: enum_num = 7 elif num == 710: enum_num = 8 elif num == 800: enum_num = 9 elif num == 900: enum_num = 10 elif num == 1000: enum_num = 11 elif num == 1100: enum_num = 12 elif num == 1300: enum_num = 13 elif num == 1400: enum_num = 14 elif num == 1600: enum_num = 15 elif num == 1800: enum_num = 16 elif num == 2000: enum_num = 17 elif num == 2200: enum_num = 18 else: enum_num_state = False return enum_num_state, enum_num def enumerate_iso_sony_a7( self, num ): enum_num = 0 enum_num_state = True if num == 0: enum_num = 0 elif num == 50: enum_num = 1 elif num == 64: enum_num = 2 elif num == 80: enum_num = 3 elif num == 100: enum_num = 4 elif num == 125: enum_num = 5 elif num == 160: enum_num = 6 elif num == 200: enum_num = 7 elif num == 250: enum_num = 8 elif num == 320: enum_num = 9 elif num == 400: enum_num = 10 elif num == 500: enum_num = 11 elif num == 640: enum_num = 12 elif num == 800: enum_num = 13 elif num == 1000: enum_num = 14 elif num == 1250: enum_num = 15 elif num == 1600: enum_num = 16 elif num == 2000: enum_num = 17 elif num == 2500: enum_num = 18 elif num == 3200: enum_num = 19 elif num == 4000: enum_num = 20 elif num == 5000: enum_num = 21 elif num == 6400: enum_num = 22 elif num == 8000: enum_num = 23 elif num == 10000: enum_num = 24 elif num == 12800: enum_num = 25 elif num == 16000: enum_num = 26 elif num == 20000: enum_num = 27 elif num == 25600: enum_num = 28 elif num == 32000: enum_num = 29 elif num == 40000: enum_num = 30 elif num == 51200: enum_num = 31 elif num == 64000: enum_num = 32 elif num == 80000: enum_num = 33 elif num == 102400: enum_num = 34 else: enum_num_state = False return enum_num_state, enum_num # Only works in movie mode # def enumerate_ex_pro_sony_a7( self, num ): enum_num = 0 enum_num_state = True if num == 32850: enum_num = 2 elif num == 32848: enum_num = 0 elif num == 32849: enum_num = 1 elif num == 32851: enum_num = 3 else: enum_num_state = False return enum_num_state, enum_num def enumerate_focus_area_sony_a7( self, num ): enum_num = 0 enum_num_state = True if ((num >= 1) and (num <= 7)): enum_num = num - 1 else: enum_num_state = False return enum_num_state, enum_num # To enable this ensure physical switch has been set to AUTO on the Lens # seemed to give a different subset of options list of 4 or 5 solved in camera "c++" # def enumerate_focus_sony_a7( self, num ): enum_num = 0 enum_num_state = True if num == 2: enum_num = 0 elif num == 4: enum_num = 1 elif num == 3: enum_num = 2 elif num == 6: enum_num = 3 elif num == 1: enum_num = 4 else: enum_num_state = False return enum_num_state, enum_num # after testing can this sometimes under certain circustances change by one ?? # Bulb 0 = 0 - This has been done in the camera "C++" # def enumerate_shutter_sony_a7( self, num ): enum_num = 0 enum_num_state = True # this occurs under certain conditions # then they all shift down by one # if num == 0: enum_num = 0 if num == 19660810: enum_num = 1 elif num == 16384010: enum_num = 2 elif num == 13107210: enum_num = 3 elif num == 9830410: enum_num = 4 elif num == 8519690: enum_num = 5 elif num == 6553610: enum_num = 6 elif num == 5242890: enum_num = 7 elif num == 3932170: enum_num = 8 elif num == 3276810: enum_num = 9 elif num == 2621450: enum_num = 10 elif num == 2097162: enum_num = 11 elif num == 1638410: enum_num = 12 elif num == 1310730: enum_num = 13 elif num == 1048586: enum_num = 14 elif num == 851978: enum_num = 15 elif num == 655370: enum_num = 16 elif num == 524298: enum_num = 17 elif num == 393226: enum_num = 18 elif num == 327690: enum_num = 19 elif num == 262154: enum_num = 20 elif num == 65539: enum_num = 21 elif num == 65540: enum_num = 22 elif num == 65541: enum_num = 23 elif num == 65542: enum_num = 24 elif num == 65544: enum_num = 25 elif num == 65546: enum_num = 26 elif num == 65549: enum_num = 27 elif num == 65551: enum_num = 28 elif num == 65556: enum_num = 29 elif num == 65561: enum_num = 30 elif num == 65566: enum_num = 31 elif num == 65576: enum_num = 32 elif num == 65586: enum_num = 33 elif num == 65596: enum_num = 34 elif num == 65616: enum_num = 35 elif num == 65636: enum_num = 36 elif num == 65661: enum_num = 37 elif num == 65696: enum_num = 38 elif num == 65736: enum_num = 39 elif num == 65786: enum_num = 40 elif num == 65856: enum_num = 41 elif num == 65936: enum_num = 42 elif num == 66036: enum_num = 43 elif num == 66176: enum_num = 44 elif num == 66336: enum_num = 45 elif num == 66536: enum_num = 46 elif num == 66786: enum_num = 47 elif num == 67136: enum_num = 48 elif num == 67536: enum_num = 49 elif num == 68036: enum_num = 50 elif num == 68736: enum_num = 51 elif num == 69536: enum_num = 52 elif num == 70536: enum_num = 53 elif num == 71936: enum_num = 54 elif num == 73536: enum_num = 55 else: enum_num_state = False return enum_num_state, enum_num def enumerate_white_bal_sony_a7( self, num ): enum_num = 0 enum_num_state = True if num == 0: enum_num = 0 elif num == 17: enum_num = 1 elif num == 18: enum_num = 2 elif num == 19: enum_num = 3 elif num == 20: enum_num = 4 elif num == 33: enum_num = 5 elif num == 34: enum_num = 6 elif num == 35: enum_num = 7 elif num == 36: enum_num = 8 elif num == 48: enum_num = 9 elif num == 1: enum_num = 10 elif num == 256: enum_num = 11 elif num == 257: enum_num = 12 elif num == 258: enum_num = 13 elif num == 259: enum_num = 14 else: enum_num_state = False return enum_num_state, enum_num #def setSonyCamISOData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): # ret = False # readSuccess = False # print(" =========== sony cam iso ================ ") # # timeout1 = timeout1 * no_timeout1_retry # timeout2 = timeout2 * no_timeout2_retry # # while (readSuccess == False) and (timeout1 > 0): # reqDat, prevDat, readSuccess = mavObj.getVal_sony_iso(mavObj.STATE_CAM_READING,timeout1) # timeout1 -= timeout1 # no retries # print("Why !!!!!!!! {readSuccess} {reqDat} {prevDat}") # print(f"set to ISO {reqDat} {prevDat} {timeout1} {mavObj.state}") # if ((not (reqDat == mavlinkSonyCamWriteVals.STATE_INIT) and not (reqDat == prevDat)) and not(timeout1 <= 0)): # ee = self.enumerate_iso_sony_a7(reqDat) # print(f"enumeration value for iso {ee} req {reqDat}") # ans = self.set_sony_iso( ee ) # print(ans) # exit(90) # if not (ans is None): # if (len(ans)==0): # print("length of command return was zero") # return ret # writeSuccess = False # while (writeSuccess == False) and (timeout2 > 0): # try: # writeSuccess = mavObj.setVal_sony_iso(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) # ret = ( ans[1] == reqDat ) # except Exception as err_msg: # print("write sony iso failed to set iso") # timeout2 -= timeout2 # no retries # if ( ret == True ): # ret = self.setSonyObjData( mem, int(ans[1]) ) #exit(200) # return ret def setSonyCamISOData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony cam iso ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # READ_TRIGGER (0) while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_iso(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 # no retries print(f"In iterator {readSuccess} {reqDat} {prevDat}") print(f"set to ISO r={reqDat} p={prevDat} time={timeout1} state={mavObj.state.value}") # LOOK FOR CHANGE (1) if ((not (int(reqDat) == mavlinkSonyCamWriteVals.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_iso_sony_a7(int(reqDat)) # INVALID CHANGE MADE (return to state == 0) if (ret == False): print(f"\033[31m Error Invalid parameter Iso {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_iso( int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2 ) timeoutS2 -= timeout2 # no retries return writeSuccess print(f"enumeration value for iso {ee} req {reqDat}") # MAKE CHANGE CAMERA RANK1 ans = self.set_sony_iso( ee ) ### MPI_Modification ::: will have to set a GLOBAL_STATE which is used as state machine ### this has to wait for MPI on other rank at this point ### when rank replies we do below. # SEND_MPI_TO_RANK1 (5) # DO ACTION IN RANK1 (6) # READ MPI_REPLY FROM RANK1 (7) # PROCESS RANK1_REPLY (8) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("setting iso the length of command return was zero") return ret if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_iso( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_ISO ) return writeSuccessWriPro_ISO print(f" \033[32m set the ISO from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_iso( int(ans[1]), mavObj.STATE_CAM_WRITING, mavObj.WRITE_PREV_DATA,timeout2 ) timeoutS2 -= timeout2 # no retries print(f" write {writeSuccess}") else: print(f" what wat {ans[1]}=={reqDat}") except Exception as err_msg: print("\033[31m write sony iso failed to set iso \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_ISO ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set iso to \033[4;42;31m {reqDat} \033[0m") #exit(200) return ret def setSonyCamApertureData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony cam aperture ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_aperture(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 # no retries if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,e = self.enumerate_aperture_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter aperture {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_aperture(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_aperture( e ) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("length of command return was zero") return ret if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_aperture( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_APER ) return writeSuccess print(f" \033[32m set the Aperture from/to :: {ans} \033[0m") # try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_aperture(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony aperture failed to set aperture \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_APER ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set aperture to \033[4;42;31m {reqDat}\033[0m") return ret def setSonyCamExProData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony ex pro ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_ex_pro(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_ex_pro_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter exposure program mode {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_ex_pro(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_ex_pro( ee ) print(f" \033[32m set the ex=Pro from/to :: {ans}\033[0m") if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("\033[31m length of command return was zero \033[0m") return ret if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_ex_pro( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_EX_PRO ) return writeSuccess # print(f" \033[32m set the ex=Pro from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_ex_pro(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony expro failed to set expro \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_EX_PRO ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set expro to \033[4;42;31m {reqDat} \033[0m") return ret def setSonyCamFocusData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony focus mode ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_focus(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_focus_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter focus mode {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_focus(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_focus( ee ) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("\033[31m length of command return was zero \033[0m") return ret # if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_focus( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_FOCUS ) return writeSuccess print(f" \033[32m set the focus mode from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_focus(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony focus mode failed to set focus mode \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_FOCUS ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set focus mode to \033[4;42;31m {reqDat} \033[0m") return ret def setSonyCamFocusAreaData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony focus area ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_focus_area(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == prevDat)) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_focus_area_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter focus area {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_focus_area(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_focus_area( ee ) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("\033[31m length of command return was zero \033[0m") return ret # if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_focus_area( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_FOCUSA ) return writeSuccess print(f" \033[32m set the focus area from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_focus_area(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony focus area failed to set focus area \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_FOCUSA ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set focus area to \033[4;42;31m {reqDat} \033[0m") return ret def setSonyCamShutSpdData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony shutter speed ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_shutter(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 print(f"set to Shutter Speed r={reqDat} p={prevDat} time={timeout1} state={mavObj.state.value}") if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_shutter_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter shutter speed {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_shutter(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) #while wpWrite == False: # wpWrite = set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_SS ) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_shutter( ee ) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("\033[31m length of command return was zero \033[0m") return ret # if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_shutter( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_SS ) return writeSuccess print(f" \033[32m set the shutter speed from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_shutter(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) print(f"written {ans[1]} {writeSuccess}") timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony shutter speed failed to set shutter speed \033[0m") if ( writeSuccess == True ): print(f"saving..... {ans[1]} {writeSuccess}") while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_SS ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set shutter speed to \033[4;42;31m {reqDat} \033[0m") return ret def setSonyCamWhiteBalaData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony white balance ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_white_bal(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_white_bal_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter white balance {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_white_bal(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_white_bal( ee ) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("\033[31m length of command return was zero \033[0m") return ret # if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_white_bal( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_WB ) return writeSuccess print(f" \033[32m set the white balance from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_white_bal(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony white balance failed to set white balance \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_WB ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set white balance to \033[4;42;31m {reqDat} \033[0m") return ret def setSonyCamStillCapModeData( self, mem, mavObj, timeout1=100, timeout2=50, no_timeout1_retry=1, no_timeout2_retry=1 ): ret = False readSuccess = False print(" =========== set sony still capture mode ================ ") # timeoutS1 = timeout1 * no_timeout1_retry # while (readSuccess == False) and (timeoutS1 > 0): reqDat, prevDat, readSuccess = mavObj.getVal_sony_still_cap_mode(mavObj.STATE_CAM_READING,timeout1) timeoutS1 -= timeout1 if ((not (int(reqDat) == mavObj.STATE_INIT) and not (int(reqDat) == int(prevDat))) and (readSuccess == True)): timeoutS2 = timeout2 * no_timeout2_retry ret,ee = self.enumerate_still_cap_sony_a7(int(reqDat)) if (ret == False): print(f"\033[31m Error Invalid parameter still capture {reqDat}\033[0m") writeSuccess = False while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_still_cap_mode(int(prevDat),mavObj.STATE_CAM_WRITING,mavObj.DONT_WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries return writeSuccess ans = self.set_sony_still_cap( ee ) if not (ans is None): writeSuccess = False wpWrite = False if (len(ans)==0): print("\033[31m length of command return was zero \033[0m") return ret # if (len(ans)==4): # thats what we return for a non-writable value if not (ans[3].find("CAN_NOT_WRITE") == -1): # if we get that we cant write it, we reset the request writeSuccess = mavObj.clearReq_sony_still_cap_mode( mavObj.STATE_CAM_WRITING ) while wpWrite == False: wpWrite = mavObj.set_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_SC ) return writeSuccess print(f" \033[32m set the still capture mode from/to :: {ans} \033[0m") try: if ( int(ans[1]) == int(reqDat) ) : while (writeSuccess == False) and (timeoutS2 > 0): writeSuccess = mavObj.setVal_sony_still_cap_mode(ans[1],mavObj.STATE_CAM_WRITING,mavObj.WRITE_PREV_DATA,timeout2) timeoutS2 -= timeout2 # no retries except Exception as err_msg: print("\033[31m write sony still capture mode failed to set still capture mode \033[0m") if ( writeSuccess == True ): while wpWrite == False: wpWrite = mavObj.clear_WritePro( mavObj.STATE_CAM_WRITING, mavObj.WriPro_SC ) ret = self.setSonyObjData( mem, int(ans[1]) ) else: ret = ( int(prevDat) == int(reqDat) ) if ret == False: print(f"\033[32m timeout error trying to set still capture mode to \033[4;42;31m {reqDat} \033[0m") return ret # # would go into mavlink class if it was in multi-tasking mode # def sendMavlinkMessageForParamObject( self, obj, the_connection, Timeout=5 ): if (obj.updateNeeded.value == True): # send mavlink message obj.name obj.signal.value obj.numberOfVals # getName, getValueforMAVSending, getPrev, myState = obj.get_value_data(obj.STATE_MAV_READING, Timeout) print(f"-------------- obj update found for param_value {getName} {getValueforMAVSending} {getPrev} {myState}") sendVal = struct.unpack('f', struct.pack('I', getValueforMAVSending))[0] if (myState == True): try: the_connection.mav.param_value_send( getName.encode('ascii'), sendVal, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, obj.numberOfVals, obj.index) ret = True except Exception as err_msg: print("Failed to send param value message : %s" % (err_msg)) ret = False if (ret == True): writeSuccess = False TimeCount = 0 while (writeSuccess == False) and (Timeout > TimeCount): # obj.updateNeeded.value = False writeSuccess = obj.set_update_flag( False, obj.STATE_MAV_WRITING ) TimeCount += 1 return ret # # would go into mavlink class if it was in multi-tasking mode # def sendMavlinkMessageForParamExtObject( self, obj, the_connection, Timeout=5 ): v, r = obj.get_ack_send( obj.STATE_MAV_READING ) if ((v == True) and (r == True)): # if (obj.ack_send.value == True): # send mavlink message obj.name obj.signal.value obj.numberOfVals # getName, getValueforMAVSending, getPrev, myState = obj.get_value_data(obj.STATE_MAV_READING, Timeout) print(f"-------------- obj update found for param_value {getName} {getValueforMAVSending} {getPrev} {myState}") if (myState == True): try: the_connection.mav.param_ext_value_send( getName.encode('ascii'), str(getValueforMAVSending).encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, obj.numberOfVals, obj.index) ret = True except Exception as err_msg: print("Failed to send param value message : %s" % (err_msg)) ret = False if (ret == True): writeSuccess = False TimeCount = 0 while (writeSuccess == False) and (Timeout > TimeCount): # obj.updateNeeded.value = False writeSuccess = obj.set_ack_send( False, obj.STATE_MAV_WRITING ) TimeCount += 1 return ret # # Pymavlink Library # Acknowledgements: # Thank you to Andrew Tridgell, the mastermind behind pymavlink and MAVProxy # Thread code from http://stackoverflow.com/questions/730645/python-wxpython-doing-work-continuously-in-the-background # Serial port code taken from http://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python # UDP http://snakeproject.ru/rubric/article.php?art=python_udp_network_server_client # AirCamPro :- 21/10/21 support android kivy serial driver # # when you install pymavlink you also need to use mavgen to generate the libraries # instructions are shown here # https://mavlink.io/en/mavgen_python/ # https://github.com/ArduPilot/pymavlink/blob/master/mavutil.py # multi-tasking info # https://ja.pymotw.com/2/multiprocessing/basics.html # https://techacademy.jp/magazine/20607 # sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml # sudo apt-get install libxml++2.6-dev # sudo pip install dronekit # ================== Compatible Joysticks ========================================= # X-Box 360 Controller (name: "Xbox 360 Controller") # Playstation 4 Controller (name: "PS4 Controller") # X-Box 360 Controller (name: "Controller (XBOX 360 For Windows)") # from pymavlink import mavutil # ref:- https://www.ardusub.com/developers/pymavlink.html #import wx import sys, serial, glob, threading # for serial message out packing import struct # this is included for android serial and to detect the android platform using kivy # ref:- https://github.com/frmdstryr/kivy-android-serial # install kivy with the following in your conda environment # conda install kivy -c conda-forge #`from kivy.utils import platform # from kvserial.driver import CdcAcmSerialPort # to list ports using the serial library from serial.tools import list_ports BUTTON_CONNECT = 10 BUTTON_ARM = 20 # ethernet UDP communication and joystick # # python3 -m pip install -U pygame --user import socket import pygame JOYSTICK_UDP_PORT = 14556 JOY_SCALE = 1000 MAX_SCALE = 32767 X_MAX = MAX_SCALE Y_MAX = MAX_SCALE MAV_TARGET = 110 MAV_SOURCE = 30 # import pymavlink.dialects.v10.lapwing as mavlink # this is a custom dialect which i cant find # this chooses version 1 you would need to change the ACK function TODO # # from mavlink_python_libs import com1 as commonV1 # import com1 as mavdefs # from mavlink_python_libs import com2 as commonV1 #from my_python_libs import com2 as commonV1 import com2 as mavdefs import math import time import array as arr #from mypymavlink import mavutilcust as custommav # # multithreading control via asyncio # import asyncio import time import numpy as np import os # ============== control Raspberry Pi IO =============== # sudo apt-get install rpi.gpio # #import RPi.GPIO as GPIO # to use Raspberry Pi board pin numbers #GPIO.setmode(GPIO.BOARD) # set up the GPIO channels - one input and one output here #GPIO.setup(11, GPIO.IN) #GPIO.setup(12, GPIO.OUT) #--------------------------------------------------------------------------- class fifo(object): def __init__(self): self.buf = [] def write(self, data): self.buf += data return len(data) def read(self): return self.buf.pop(0) import re # mavlink communicator class (without GUI) # class MAVFrame(): RCV_COMMAND = mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE RPM2 = 0 ACK_RESULT = mavutil.mavlink.MAV_RESULT_UNSUPPORTED DEFAULT_SYS_ID = 1 ACK_ALL_DATA_COMPLETE = 99 CAMERA_INFORMATION = 259 #camera_information CAMERA_SETTINGS = 260 STORAGE_INFORMATION = 261 CAMERA_CAPTURE_STATUS = 262 CAMERA_IMAGE_CAPTURED = 263 VIDEO_STREAM = 269 # camera informations (default camera routines will retrieve this) time_boot_ms = 1 firmware_version = 12 focal_length = 1.1 sensor_size_h = 3.0 sensor_size_v = 4.0 flags = 4 resolution_h = 300 resolution_v = 400 cam_definition_version = 2 #vendor_name_nd = np.dtype([('A',np.uint8)]) #model_name_nd = np.dtype([('B',np.uint8)]) #vendor_name_list = [65] #model_name_list = [67] #vendor_name = "A" #model_name = "B" lens_id = 1 cam_definition_uri = "http://10.0.2.51/cam_defs" # camera settings mode_id = 3 # Camera mode zoomLevel = 7 # Current zoom level (0.0 to 100.0, NaN if not known)*/ focusLevel = 9 # storage informations total_capacity = 1.2 # [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored. used_capacity = 1.1 # [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored. available_capacity = 0.1 # [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored. read_speed = 0.67 # [MiB/s] Read speed. write_speed = 0.76 # [MiB/s] Write speed. storage_id = 1 # Storage ID (1 for first, 2 for second, etc.) storage_count = 2 # Number of storage devices status = 0 #status = mavutil.mavlink.STORAGE_STATUS_READY # camera capture status image_interval = 3.3 # [s] Image capture interval recording_time_ms = 10000 # [ms] Time since recording started available_capacity = 0.34 # [MiB] Available storage capacity. image_status = 1 # Current status of image capturing (0: idle, 1: capture in progress, 2: interval set but idle, 3: interval set and capture in progress) video_status = 1 # Current status of video capturing (0: idle, 1: capture in progress) image_count = 11 # video stream framerate = 30.0 # [Hz] Frame rate. bitrate = 3000 # [bits/s] Bit rate. Vflags = 3 # Bitmap of stream status flags. Vresolution_h = 300 # [pix] Horizontal resolution. Vresolution_v = 400 # [pix] Vertical resolution. rotation = 90 # [deg] Video image rotation clockwise. hfov = 45 # [deg] Horizontal Field of view. stream_id = 2 # Video Stream ID (1 for first, 2 for second, etc.) count = 4 # Number of streams available. stream_type = mavutil.mavlink.VIDEO_STREAM_TYPE_MPEG_TS_H264 # Type of stream. videoname = "vid_001" video_uri = "http://10.0.0.56/vids/001.mov" # camera image captured time_utc = 667700 # [us] Timestamp (time since UNIX epoch) in UTC. 0 for unknown. lat = 30 # [degE7] Latitude where image was taken lon = 40 # [degE7] Longitude where capture was taken alt = 11 # [mm] Altitude (MSL) where image was taken relative_alt = 12 # [mm] Altitude above ground q = [1,0,0,0] # Quaternion of camera orientation (w, x, y, z order, zero-rotation is 0, 0, 0, 0) image_index = 4 # Zero based index of this image (image count since armed -1) camera_id = 1 # Camera ID (1 for first, 2 for second, etc.) capture_result = 1 # Boolean indicating success (1) or failure (0) while capturing this image. file_url = "http://10.1.2.3/img/1.jpg" # camera feedback time_usec = 10000 cam_idx = 1 img_idx = 1 # already lat, lng = lon alt_msl = 2 alt_rel = 4 roll = 6 pitch = 1 yaw = 2 foc_len = 7 CFflags = 3 ACK_ERROR = 0 errRCV_COMMAND = 0 errRPM2 = 0 # task control flag # task_control_1 = 0 # global constants # GOT_ERROR = 1 GOT_SUCCESS = 2 GOT_BAD = 3 GOT_UNFORMAT = 4 # used to decide what is being requested from the calling (GCS) station # type_of_msg = 0 g_count = 0 pin_no = 0 # defines for camera ID file # CAM_XML_FILE = "alpha_cam_new.xml" NETWORK_ID = 1 def __init__(self, pinNum=26): #self.setUPPiRelayNumBCM() #self.setPinINput(pinNum) MAVFrame.pin_no=pinNum def __del__(self): class_name = self.__class__.__name__ print('{} Deleted'.format(class_name)) # # check our operating system we mostly at present only support linux # def check_os( self ): if ((sys.platform=='linux2') or (sys.platform=='linux')): return 1 elif sys.platform=='win32': return 2 else: return 3 def update_utc_label( self ): if (self.check_os() == 1): cmd = "date +%s" self.time_utc = os.popen(cmd).read() def update_uptime_label( self ): if (self.check_os() == 1): cmd = "uptime" upTimStr = os.popen(cmd).read().split(",") dd = upTimStr[0].split() days = int(dd[2]) xx = dd[0].split(":") hours = int(xx[0]) mins = int(xx[1]) secs = int(xx[2]) self.time_boot_ms = (days*60*60*24) + (hours*60*60) + (mins*60) + secs #print(f"boot tim {self.time_boot_ms} { (days*60*60*24) + (hours*60*60) + (mins*60) + secs }") def on_click_connect(self,e): #""" #Process a click on the CONNECT button #Attempt to connect to the MAV using the specified port and baud rate, #then subscribe a function called check_heartbeat that will listen for #a heartbeat message, as well as a function that will print all incoming #MAVLink messages to the console. #""" port = self.cb_port.GetValue() baud = int(self.cb_baud.GetValue()) self.textOutput.AppendText("Connecting to " + port + " at " + str(baud) + " baud\n") self.master = mavutil.mavlink_connection(port, baud=baud) self.thread = threading.Thread(target=self.process_messages) self.thread.setDaemon(True) self.thread.start() self.master.message_hooks.append(self.check_heartbeat) self.master.message_hooks.append(self.check_rcv_data_msg) self.master.message_hooks.append(self.log_message) print("Connecting to " + port + " at " + str(baud) + "baud") self.textOutput.AppendText("Waiting for APM heartbeat\n") return def on_click_arm(self,e): #""" #Process a click on the ARM button #Send an arm message to the MAV, then subscribe a function called #check_arm_ack that will listen for a positive confirmation of arming. # """ self.textOutput.AppendText("Arming motor\n") print("******arming motor*********") self.master.arducopter_arm() self.master.message_hooks.append(self.check_arm_ack) def log_message(self,caller,msg): if msg.get_type() != 'BAD_DATA': print(str(msg)) return def process_messages(self): #""" #This runs continuously. The mavutil.recv_match() function will call mavutil.post_message() #any time a new message is received, and will notify all functions in the master.message_hooks list. #""" while True: msg = self.master.recv_match(blocking=True) if not msg: return if msg.get_type() == "BAD_DATA": if mavutil.all_printable(msg.data): sys.stdout.write(msg.data) sys.stdout.flush() def check_heartbeat(self,caller,msg): #""" #Listens for a heartbeat message #Once this function is subscribed to the dispatcher, it listens to every #incoming MAVLINK message and watches for a 'HEARTBEAT' message. Once #that message is received, the function updates the GUI and then # unsubscribes itself. #" "" if msg.get_type() == 'HEARTBEAT': self.textOutput.AppendText("Heartbeat received from APM (system %u component %u)\n" % (self.master.target_system, self.master.target_component)) self.master.message_hooks.remove(self.check_heartbeat) def check_arm_ack(self, caller, msg): #""" #Listens for confirmation of motor arming #Once this function is subscribed to the dispatcher, it listens to every #incomign MAVLINK message and watches for the "Motor armed!" confirmation. #Once the message is received, teh function updates the GUI and then #unsubscribes itself. #""" if msg.get_type() == 'STATUSTEXT': if "Throttle armed" in msg.text: self.textOutput.AppendText("Motor armed!") self.master.message_hooks.remove(self.check_arm_ack) def check_rcv_data_msg(self, msg): if msg.get_type() == 'RC_CHANNELS': self.textOutput.AppendText("RC Channel message (system %u component %u)\n" % (self.master.target_system, self.master.target_component)) self.textOutput.AppendText("chan1 %u chan2 %u)\n" % (self.master.chan1_raw, self.master.chan2_raw)) self.master.message_hooks.remove(self.check_rcv_data_msg) elif msg.get_type() == 'COMMAND_LONG': self.textOutput.AppendText("Long message received (system %u component %u)\n" % (self.master.target_system, self.master.target_component)) self.textOutput.AppendText("Command %u p1 %u p2 %u p3 %u p4 %u \n" % (self.master.command, self.master.param1, self.master.param2, self.master.param3, self.master.param4)) self.textOutput.AppendText("p5 %u p6 %u p7 %u \n" % (self.master.param5, self.master.param6, self.master.param7)) self.master.message_hooks.remove(self.check_rcv_data_msg) elif msg.get_type() == 'CAMERA_IMAGE_CAPTURED': self.textOutput.AppendText("Cam Cap message received (system %u component %u)\n" % (self.master.target_system, self.master.target_component)) self.textOutput.AppendText("lat %u lon %u alt %u\n" % (self.master.lat, self.master.lon, self.master.alt)) self.textOutput.AppendText("URL %u)\n" % (self.master.file_url)) self.master.message_hooks.remove(self.check_rcv_data_msg) def OnClose(self, e): self._mgr.UnInit() self.Close() # if you want this then uncomment these lines for the android kivy libraries as well (instructions to install are above) #`from kivy.utils import platform # from kvserial.driver import CdcAcmSerialPort def serial_ports(self): # Lists all available serial ports #:raises EnvironmentError: # On unsupported or unknown platforms #:returns: # A list of available serial ports # if 'ANDROID_BOOTLOGO' in os.environ: # detect android first as if using sys alone, it returns linux #if platform == 'android': using kivy instead ports = '/dev/ttyACM0' else: if sys.platform.startswith('win'): ports = ['COM' + str(i + 1) for i in range(256)] elif sys.platform.startswith('linux') or sys.platform.startswith('linux2') or sys.platform.startswith('cygwin'): # check this shows /dev/ttyAMA0 on raspberry pi. # this is to exclude your current terminal "/dev/tty" ports = glob.glob('/dev/tty[A-Za-z]*') elif sys.platform.startswith('darwin'): # apple mac support if using darwin ports = glob.glob('/dev/tty.*') else: ports = list_ports.comports() # Outputs list of available serial ports should do the rest e.g. riscos atheos os2 freebsd aix etc if len(ports) == 0: raise EnvironmentError('Unsupported platform') result = [] for port in ports: if 'ANDROID_BOOTLOGO' in os.environ: # device android s = CdcAcmSerialPort(port) s.close() result.append(port) else: try: s = serial.Serial(port) s.close() result.append(port) except (OSError, serial.SerialException): pass return result def print_red(self,text,value): print("\033[31m %s : %6.3f"%(text,value)) def print_yellow(self,text,value): print("\033[33m %s : %6.3f"%(text,value)) def print_2_yellow(self,text,value1,value2): print("\033[33m %s : %6.3f %6.3f"%(text,value1,value2)) def print_3_yellow(self,text,value1,value2,value3): print("\033[33m %s : %6.3f %6.3f %6.3f"%(text,value1,value2,value3)) def print_3_blue(self,text,value1,value2,value3): print("\033[34m %s %6.3f %6.3f %6.3f"%(text,value1,value2,value3)) def print_blue(self,text,value): print("\033[34m %s : %6.3f"%(text,value)) def joystickInit(self): # Set the width and height of the screen [width,height] size = [500, 700] screen = pygame.display.set_mode(size) pygame.display.set_caption("----- My test of mavlink and joystick -----") pygame.init() # Used to manage how fast the screen updates clock = pygame.time.Clock() # Initialize the joysticks pygame.joystick.init() joystick = pygame.joystick.Joystick(0) joystick.init() # Get ready to print textPrint = TextPrint() def initUDPSocket(self,bind): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # bind the socket if this is a server (pass bind==1) if bind == 1: host = 'localhost' port = JOYSTICK_UDP_PORT sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) addr = (host,port) sock.bind(addr) sock.setblocking(0) return sock def closeUDPSocket(self,udp_socket): udp_socket.close() def serverReadUDPSocket(self,udp_socket,port): conn, addr = udp_socket.recvfrom(port) return conn,addr def clientReadUDPSocket(self,udp_socket,port): dataV = udp_socket.recvfrom(port) return dataV def joyMavlinkInit(self): mav = mavutil.mavlink.MAVLink(fifo()) mav.srcSystem = MAV_SOURCE # set to master def blockMouseDown(self,block_flag): if block_flag: pygame.event.set_blocked(pygame.MOUSEBUTTONDOWN) else: pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN) def blockMouseUp(self,block_flag): if block_flag: pygame.event.set_blocked(pygame.MOUSEBUTTONUP) else: pygame.event.set_allowed(pygame.MOUSEBUTTONUP) def checkMouseDwnBlock(self): print ('MOUSEBUTTONDOWN is block: ', pygame.event.get_blocked(pygame.MOUSEBUTTONDOWN)) def checkMouseUpBlock(self): print ('MOUSEBUTTONUP is block: ', pygame.event.get_blocked(pygame.MOUSEBUTTONUP)) def write_mav_serial_data(self, serial, x ): serial.write(struct.pack(x)) def write_pack_serial_data(self, serial, x, y, z, roll, pitch, yaw): serial.write(struct.pack('<chhhhhh', 'S',x, y, z, roll, pitch, yaw)) def test_linear(self, serial, lenght=200, times=1000, delta=0.05): for angle in xrange(1, times, 5): a = angle * math.pi / 180 self.write_serial_data(serial, int(lenght * math.cos(a)), int(lenght * math.sin(a)),0,0,0,0) time.sleep(delta) self.write_serial_data(serial, 0,0,0,0,0,0) def test_angles(self, serial, lenght=200, times=1000, delta=0.05): for angle in xrange(1, times, 5): a = angle * math.pi / 180 self.write_serial_data(0, 0,0,0,int(30 * math.cos(a)),int(30 * math.sin(-a))) time.sleep(delta) self.write_serial_data(serial, 0,0,0,0,0,0) def test_yaw(self, serial, lenght=200, times=1000, delta=0.05): for angle in xrange(1, times, 5): a = angle * math.pi / 180 self.write_serial_data(serial, int(lenght * math.cos(a)),0,0,int(30 * math.sin(a)),0,0) time.sleep(delta) self.write_serial_data(serial, 0,0,0,0,0,0) def processJoystickSendMavlink(self,sock): msgbuf = None # -------- Main Program Loop ----------- while done == False: btns = 0 thrust = 0.0 rudder = 0.0 # EVENT PROCESSING STEP for event in pygame.event.get(): # User did something screen.fill(WHITE) textPrint.reset() # Possible joystick actions: JOYAXISMOTION JOYBALLMOTION JOYBUTTONDOWN JOYBUTTONUP JOYHATMOTION # QUIT - none # ACTIVEEVENT - gain, state # KEYDOWN - unicode, key, mod # KEYUP - key, mod # MOUSEMOTION - pos, rel, buttons # MOUSEBUTTONUP - pos, button # MOUSEBUTTONDOWN - pos, button # JOYAXISMOTION - joy, axis, value # JOYBALLMOTION - joy, ball, rel # JOYHATMOTION - joy, hat, value # JOYBUTTONUP - joy, button # JOYBUTTONDOWN - joy, button # VIDEORESIZE - size, w, h # VIDEOEXPOSE - none # USEREVENT – code if event.type == pygame.QUIT: done=True elif event.type == pygame.MOUSEBUTTONDOWN: self.print_2_yellow("Mouse button down pressed.",event.button,event.pos) elif event.type == pygame.MOUSEBUTTONUP: self.print_2_yellow("Mouse button up pressed.",event.button,event.pos) elif event.type == pygame.JOYBUTTONDOWN: self.print_2_yellow("Joystick button down pressed.",event.button,event.joy) elif event.type == pygame.JOYBUTTONUP: self.print_2_yellow("Joystick button up released.",event.button,event.joy) elif event.type == pygame.JOYAXISMOTION: self.print_3_yellow("Joystick axis motion.",event.joy,event.axis,event.value) elif event.type == pygame.JOYBALLMOTION: self.print_3_yellow("Joystick ball motion.",event.joy,event.ball,event.rel) elif event.type == pygame.JOYHATMOTION: self.print_3_yellow("Joystick hat motion",event.joy,event.hat,event.value) elif event.type == pygame.VIDEORESIZE: self.print_3_blue("video re-size.",event.size,event.w,event.h) elif event.type == pygame.KEYDOWN: self.print_3_yellow("key down ",event.unicode,event.key,event.mod) elif event.type == pygame.KEYUP: self.print_2_yellow("key up ",event.key,event.mod) # Get the name from the OS for the controller/joystick name = joystick.get_name() print("Joystick name: {}".format(name) ) # get the buttons buttons = joystick.get_numbuttons() for i in range( buttons ): button = joystick.get_button( i ) print( "Button {:>2} value: {}".format(i,button) ) # get the hats # Hat switch. All or nothing for direction, not like joysticks. # Value comes back in an array. hats = joystick.get_numhats() print( "Number of hats: {}".format(hats) ) textPrint.indent() for i in range( hats ): hat = joystick.get_hat( i ) print( "Hat {} value: {}".format(i, str(hat)) ) # Getting available devices for id in range(pygame.joystick.get_count()): print( "devices list : %u %d %s" % (id, pygame.joystick.Joystick(id).get_name())) # Get thrust and break first # mix 2 shifts in single channels thr = (joystick.get_axis(5) + 1) / 2 brk = -(joystick.get_axis(2) + 1) / 2 thrust = thr + brk self.print_yellow("Thrust value ",thrust) # this is the x axis rudder = joystick.get_axis(0) self.print_blue("Rudder value ",rudder) # now collect all buttons btns = 0 for i in range(joystick.get_numbuttons()): btns |= joystick.get_button(i) << i # Usually axis run in pairs, up/down for one, and left/right for # the other. axes = joystick.get_numaxes() print( "Number of axes: {}".format(axes) ) textPrint.indent() for i in range( axes ): axis = joystick.get_axis( i ) print( "Axis {} value: {:>6.3f}".format(i, axis) ) textPrint.unindent() # Update events in pygame pygame.event.pump() # pack acquired data and throw it to socket msg = mavutil.mavlink.MAVLink_manual_control_message( target = MAV_TARGET, x = X_MAX, y = Y_MAX, z = round(thrust*JOY_SCALE), r = round(rudder*JOY_SCALE), buttons = btns) msgbuf = msg.pack(mav) try: jid = joystick.get_instance_id() except AttributeError: # get_instance_id() is an SDL2 method jid = joystick.get_id() print( "Joystick {}".format(jid)) try: guid = joystick.get_guid() except AttributeError: # get_guid() is an SDL2 method pass else: print("GUID: {}".format(guid)) # Limit to 20 frames per second clock.tick(25) if msgbuf: # send the message on the UDP Port sock.sendto(msgbuf, ('', JOYSTICK_UDP_PORT)) # send the message on serial # write_mav_serial_data(serial, msgbuf) # Close the window and quit. # If you forget this line, the program will 'hang' # on exit if running from IDLE. pygame.joystick.quit() pygame.quit() # make a mavlink connection using mavutil like ardusub does.... # # Create the connection and return it for use with the other functions # # TODO::: change the port and see if this can run entirely paralel with camera # take picture on another port # def makeMAVlinkConn(self): try: #the_conection = mavutil.mavlink_connection('udpin:127.0.0.1:14551',autoreconnect=True) the_conection = mavutil.mavlink_connection('udpin:0.0.0.0:14550',autoreconnect=True, source_system=1, source_component=100) return the_conection,True except Exception as err_msg: print("Failed to connect : %s" % (err_msg)) return the_conection,False def makeNewMAVlinkConn(self,id): try: #the_conection = mavutil.mavlink_connection('udpin:127.0.0.1:14551',autoreconnect=True, source_system=id) the_conection = mavutil.mavlink_connection('udpin:0.0.0.0:14550',autoreconnect=True, source_system=id, source_component=100) return the_conection,True except Exception as err_msg: print("Failed to connect : %s" % (err_msg)) return the_conection,False # Send heartbeat from camera to GCS (types are define as enum in the dialect file). # def mavlink_send_GCS_heartbeat(self, the_conection): print(" heartbeat.............................. %s\n"%(mavutil.mavlink.MAV_TYPE_CAMERA)) try: the_conection.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_CAMERA, mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, mavutil.mavlink.MAV_STATE_ACTIVE) ret = True except Exception as err_msg: print("Failed to send GCS heartbeat : %s" % (err_msg)) ret = False print(" heartbeat.............................. %s\n"%(ret)) return ret # Send heartbeat from a MAVLink application. # def mavlink_send_OBC_heartbeat2(self, the_connection): try: mavutil.mavlink.heartbeat_send(mavutil.mavlink.MAV_TYPE_CAMERA, mavutil.mavlink.MAV_AUTOPILOT_GENERIC, 0, 0, 0) ret = True except Exception as err_msg: print("Failed to send OBC heartbeat : %s" % (err_msg)) ret = False return ret # Receive heartbeat from a MAVLink application. # def mavlink_rcv_heartbeat(self, the_connection): try: the_connection.wait_heartbeat() ret = True except Exception as err_msg: print("Failed to wait for heartbeat : %s" % (err_msg)) ret = False return ret # Sets a value to the rc channel # def mavlink_set_rc_channel_pwm(self, the_connection, channel_id, pwm=1500): #""" Set RC channel pwm value #Args: # channel_id (TYPE): Channel ID # pwm (int, optional): Channel pwm value 1100-1900 #""" if channel_id < 1 or channel_id > 18: print("Channel does not exist.") return # Mavlink 2 supports up to 18 channels: # https://mavlink.io/en/messages/common.html#RC_CHANNELS_OVERRIDE rc_channel_values = [65535 for _ in range(18)] rc_channel_values[channel_id - 1] = pwm try: the_connection.mav.rc_channels_override_send( the_connection.target_system, the_connection.target_component, *rc_channel_values ) ret = True except Exception as err_msg: print("Failed to set RC Chan PWM : %s" % (err_msg)) ret = False return ret # drives a gimbal axis controller to the pitch roll yaw specified # def gimbal_move_to( self, the_connection, tilt=0, roll=0, pan=0): #""" #Moves gimbal to given position try: the_connection.mav.command_long_send(the_connection.target_system, the_connection.target_component, mavutil.mavlink.MAV_CMD_DO_MOUNT_CONTROL, 1, tilt, roll, pan, 0, 0, 0, mavutil.mavlink.MAV_MOUNT_MODE_MAVLINK_TARGETING) ret = True except Exception as err_msg: print("Failed to move gimbal using command long : %s" % (err_msg)) ret = False return ret def mavlink10(self,connID): # '''return True if using MAVLink 1.0 or later''' return float(connID.WIRE_PROTOCOL_VERSION) >= 1 def mavlink20(self,connID): # '''return True if using MAVLink 2.0 or later''' return float(connID.WIRE_PROTOCOL_VERSION) >= 2 # Set relay_pin to value of state def mavlink_set_relay(self, the_connection, relay_pin=0, state=True): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_DO_SET_RELAY, # command 0, # Confirmation relay_pin, # Relay Number int(state), # state (1 to indicate arm) 0, # param3 (all other params meaningless) 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to set relay using command long : %s" % (err_msg)) ret = False return ret # ref:- https://mavlink.io/en/messages/common.html#MAV_CMD def mavlink_video_stop_capture(self, the_connection, streamNo): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_VIDEO_STOP_CAPTURE, # command 0, # Confirmation streamNo, # stream number 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to stop video capture using command long : %s" % (err_msg)) ret = False return ret def mavlink_video_start_capture(self, the_connection, streamNo, freq): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_VIDEO_START_CAPTURE, # command 0, # Confirmation streamNo, # stream number freq, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to start video capture using command long : %s" % (err_msg)) ret = False return ret def mavlink_image_stop_capture(self, the_connection): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_IMAGE_STOP_CAPTURE, # command 0, # Confirmation 0, # param1 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to stop image capture using command long : %s" % (err_msg)) ret = False return ret def mavlink_image_start_capture(self, the_connection, interval, totalImages, seqNo): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_IMAGE_START_CAPTURE, # command 0, # Confirmation 0, # param1 interval, # Desired elapsed time between two consecutive pictures (in seconds) totalImages, # Total number of images to capture. 0 to capture forever/until MAV_CMD_IMAGE_STOP_CAPTURE. seqNo, # Capture sequence number starting from 1. This is only valid for single-capture (param3 == 1), otherwise set to 0. Increment the capture ID for each capture command to prevent double captures when a command is re-transmitted 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to start image capture using command long : %s" % (err_msg)) ret = False return ret def mavlink_video_stop_streaming(self, the_connection, streamNo): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_VIDEO_STOP_STREAMING, # command 0, # Confirmation streamNo, # stream number 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to send stop streaming using command long : %s" % (err_msg)) ret = False return ret def mavlink_do_ftp_send(self, the_connection, network, payload): MAX_CHUNK_BYTES = 251 numOfchunk = round(len(payload) / MAX_CHUNK_BYTES) for i in range(numOfchunk): #print(f"ftp send chunk {i} offset {i*251}") msgpay = [] b = 1 for b in range(MAX_CHUNK_BYTES): try: msgpay.append(payload[b+(i*251)]) except Exception as e: msgpay.append(0) try: the_connection.mav.file_transfer_protocol_send ( network, the_connection.target_system, # target_system the_connection.target_component, # target_component msgpay ) except Exception as e: print(f" ftp send exception {e} \nchunk {i} @ offset {i*MAX_CHUNK_BYTES}") def mavlink_video_start_streaming(self, the_connection, streamNo): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_VIDEO_START_STREAMING, # command 0, # Confirmation streamNo, # stream number 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to send start streaming using command long : %s" % (err_msg)) ret = False return ret # suitable variables to drive CamMode # MAV_CAMERA_MODE_IMAGE = 0 MAV_CAMERA_MODE_VIDEO = 1 MAV_CAMERA_MODE_IMAGE_SURVEY = 2 def mavlink_video_set_camera_mode(self, the_connection, camMode): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_SET_CAMERA_MODE, # command 0, # Confirmation 0, # param1 camMode, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to send video set camera mode using command long : %s" % (err_msg)) ret = False return ret # suitable variables to drive CamZoomType # MAV_ZOOM_TYPE_STEP = 0 # Zoom one step increment (-1 for wide, 1 for tele) MAV_ZOOM_TYPE_CONTINUOUS = 1 # Continuous zoom up/down until stopped (-1 for wide, 1 for tele, 0 to stop zooming) MAV_ZOOM_TYPE_RANGE = 2 # Zoom value as proportion of full camera range (a value between 0.0 and 100.0) MAV_ZOOM_TYPE_FOCAL_LENGTH = 3 # Zoom value/variable focal length in milimetres def mavlink_video_set_camera_zoom(self, the_connection, camZoomType, camZoomValue): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_SET_CAMERA_MODE, # command 0, # Confirmation camZoomType, # param1 camZoomValue, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to send camera zoom using command long : %s" % (err_msg)) ret = False return ret MAV_FOCUS_TYPE_STEP = 0 # Focus one step increment (-1 for focusing in, 1 for focusing out towards infinity). MAV_FOCUS_TYPE_CONTINUOUS = 1 # Continuous focus up/down until stopped (-1 for focusing in, 1 for focusing out towards infinity, 0 to stop focusing) MAV_FOCUS_TYPE_RANGE = 2 # Focus value as proportion of full camera focus range (a value between 0.0 and 100.0) MAV_FOCUS_TYPE_METERS = 3 # Focus value in metres def mavlink_video_set_camera_focus(self, the_connection, camFocusType, camFocusValue): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavdefs.MAV_CMD_SET_CAMERA_FOCUS, # command 0, # Confirmation camFocusType, # param1 camFocusValue, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to send camera focus using command long : %s" % (err_msg)) ret = False return ret def mavlink_do_digicam_configure(self, the_connection, camMode, camShutterSpeed, camAperture, camISO, camExposure, camCommandIdentity, camEngineCutOff): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONFIGURE, # command 0, # Confirmation camMode, # param1 camShutterSpeed, # param2 camAperture, # param3 camISO, # param4 camExposure, # param5 camCommandIdentity, # param6 camEngineCutOff) # param7 ret = True except Exception as err_msg: print("Failed to send digicam configure using command long : %s" % (err_msg)) ret = False return ret def mavlink_do_digicam_control(self, the_connection, camSessionControl, camZoomAbsolute, camZoomRelative, camFocus, camShootCommand, camCommandIdentity, camShotID): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONTROL, # command 0, # Confirmation camSessionControl, # param1 camZoomAbsolute, # param2 camZoomRelative, # param3 camFocus, # param4 camShootCommand, # param5 camCommandIdentity, # param6 camShotID) # param7 ret = True except Exception as err_msg: print("Failed to send digicam control using command long : %s" % (err_msg)) ret = False return ret def mavlink_do_video_control(self, the_connection, camID, camTransmission, camInterval, camRecording): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_DO_CONTROL_VIDEO, # command 0, # Confirmation camID, # param1 camTransmission, # param2 camInterval, # param3 camRecording, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to send do video control using command long : %s" % (err_msg)) ret = False return ret def mavlink_get_camera_settings(self, the_connection): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_SETTINGS, # command 0, # Confirmation 1, # param1 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to get cam settings using command long : %s" % (err_msg)) ret = False return ret def mavlink_get_storage_info(self, the_connection, StoId): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_REQUEST_STORAGE_INFORMATION, # command 0, # Confirmation StoId, # param1 1, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to get storage info using command long : %s" % (err_msg)) ret = False return ret def mavlink_get_capture_status(self, the_connection): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_CAPTURE_STATUS, # command 0, # Confirmation 1, # param1 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to get capture status using command long : %s" % (err_msg)) ret = False return ret def mavlink_get_stream_info(self, the_connection): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_REQUEST_VIDEO_STREAM_INFORMATION, # command 0, # Confirmation 1, # param1 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to get stream info using command long : %s" % (err_msg)) ret = False return ret def mavlink_reset_camera(self, the_connection): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_RESET_CAMERA_SETTINGS, # command 0, # Confirmation 1, # param1 0, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to reset camera using command long : %s" % (err_msg)) ret = False return ret def mavlink_set_camera_trig_interval(self, the_connection, camTriggerCycle, camShutterIntegration): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL, # command 0, # Confirmation camTriggerCycle, # param1 camShutterIntegration, # param2 0, # param3 0, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to set camera trip interval using command long : %s" % (err_msg)) ret = False return ret def mavlink_set_camera_to_quaternion(self, the_connection, q1, q2, q3, q4): #if self.mavlink10(): try: the_connection.mav.command_long_send( the_connection.target_system, # target_system the_connection.target_component, # target_component mavutil.mavlink.MAV_CMD_DO_MOUNT_CONTROL_QUAT, # command 0, # Confirmation q1, # param1 q2, # param2 q3, # param3 q4, # param4 0, # param5 0, # param6 0) # param7 ret = True except Exception as err_msg: print("Failed to set camera to quartenion using command long : %s" % (err_msg)) ret = False return ret # convert to integer param_value from mavlink # def mav_param_type_conv( self, typ, value ): if ( int(mavutil.mavlink.MAV_PARAM_TYPE_INT64) >= int(typ) ): return int(struct.unpack('I', struct.pack('f', value))[0]) else: return value # convert an integer param_value to be sent on mavlink # def param_to_mav_msg_conv( self, typ, value ): if ( int(mavutil.mavlink.MAV_PARAM_TYPE_INT64) >= int(typ) ): return float(struct.unpack('f', struct.pack('I', value))[0]) else: return value # param_value handlers : seperate ones to allow changes in data type etc # def mavlink_send_param_value_iso(self, the_connection, val ): print("\033[36m sending a parameter : iso ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_ISO".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 1) return True except Exception as err_msg: print("Failed to send param value message 1: %s" % (err_msg)) return False def mavlink_send_param_value_aper(self, the_connection, val ): print("\033[31m sending a parameter : aperture ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_APERTURE".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 2) return True except Exception as err_msg: print("Failed to send param value message 2: %s" % (err_msg)) return False def mavlink_send_param_value_expro(self, the_connection, val ): print("\033[32m sending a parameter : expro ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_EX_PRO_MODE".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 3) return True except Exception as err_msg: print("Failed to send param value message 3: %s" % (err_msg)) return False def mavlink_send_param_value_focus(self, the_connection, val ): print("\033[33m sending a parameter : focus mode ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_FOCUS_MODE".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 4) return True except Exception as err_msg: print("Failed to send param value message 4: %s" % (err_msg)) return False def mavlink_send_param_value_focus_area(self, the_connection, val ): print("\033[34m sending a parameter : focus area ") p = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_FOCUS_AREA".encode('ascii'), p, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 5) return True except Exception as err_msg: print("Failed to send param value message 5: %s" % (err_msg)) return False def mavlink_send_param_value_shut_spd(self, the_connection, val ): print("\033[35m sending a parameter : shutter speed ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_SHUT_SPD".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 6) return True except Exception as err_msg: print("Failed to send param value message 6: %s" % (err_msg)) return False def mavlink_send_param_value_white_bal(self, the_connection, val ): print("\033[37m sending a parameter : white balance ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_WHITE_BAL".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 7) return True except Exception as err_msg: print("Failed to send param value message 7: %s" % (err_msg)) return False def mavlink_send_param_value_still_cap(self, the_connection, val ): print("\033[38m sending a parameter : still capture mode ") d = struct.unpack('f', struct.pack('I', val))[0] try: the_connection.mav.param_value_send( "S_STILL_CAP".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 8) return True except Exception as err_msg: print("Failed to send param value message 8: %s" % (err_msg)) return False def mavlink_send_param_ext_value_iso(self, the_connection, val ): print("\033[31m sending an ext parameter iso") d = str(val) try: the_connection.mav.param_ext_value_send( "S_ISO".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 1) return True except Exception as err_msg: print("Failed to send param value message 1: %s" % (err_msg)) return False def mavlink_send_param_ext_value_aper(self, the_connection, val ): print("\033[32m sending an ext parameter aper") d = str(val) try: the_connection.mav.param_ext_value_send( "S_APERTURE".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 2) return True except Exception as err_msg: print("Failed to send param value message 2: %s" % (err_msg)) return False def mavlink_send_param_ext_value_expro(self, the_connection, val ): print("\033[33m sending an ext parameter expro") d = str(val) try: the_connection.mav.param_ext_value_send( "S_EX_PRO_MODE".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 3) return True except Exception as err_msg: print("Failed to send param value message 3: %s" % (err_msg)) return False def mavlink_send_param_ext_value_focus(self, the_connection, val ): print("\033[34m sending an ext parameter focus") d = str(val) try: the_connection.mav.param_ext_value_send( "S_FOCUS_MODE".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 4) return True except Exception as err_msg: print("Failed to send param value message 4: %s" % (err_msg)) return False def mavlink_send_param_ext_value_focus_area(self, the_connection, val ): print("\033[35m sending an ext parameter focus area") p = str(val) try: the_connection.mav.param_ext_value_send( "S_FOCUS_AREA".encode('ascii'), p.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 5) return True except Exception as err_msg: print("Failed to send param value message 5: %s" % (err_msg)) return False def mavlink_send_param_ext_value_shut_spd(self, the_connection, val ): print("\033[36m sending an ext parameter shutter speed") d = str(val) try: the_connection.mav.param_ext_value_send( "S_SHUT_SPD".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 6) return True except Exception as err_msg: print("Failed to send param value message 6: %s" % (err_msg)) return False def mavlink_send_param_ext_value_white_bal(self, the_connection, val ): print("\033[37m sending an ext parameter white balance") d = str(val) try: the_connection.mav.param_ext_value_send( "S_WHITE_BAL".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 7) return True except Exception as err_msg: print("Failed to send param value message 7: %s" % (err_msg)) return False def mavlink_send_param_ext_value_still_cap(self, the_connection, val ): print("\033[37m sending an ext parameter still capture") d = str(val) try: the_connection.mav.param_ext_value_send( "S_STILL_CAP".encode('ascii'), d.encode('ascii'), mavdefs.MAV_PARAM_EXT_TYPE_UINT32, 8, 8) return True except Exception as err_msg: print("Failed to send param value message 8: %s" % (err_msg)) return False def mavlink_send_param_value(self, the_connection): print("\033[36m sending a parameter") d = struct.unpack('f', struct.pack('I', 1))[0] try: the_connection.mav.param_value_send( "S_ISO".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 1) ret = True except Exception as err_msg: print("Failed to send param value message 1: %s" % (err_msg)) ret = False d = struct.unpack('f', struct.pack('I', 10))[0] try: the_connection.mav.param_value_send( "S_APERTURE".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 2) ret = True except Exception as err_msg: print("Failed to send param value message 2: %s" % (err_msg)) ret = False d = struct.unpack('f', struct.pack('I', 30))[0] try: the_connection.mav.param_value_send( "S_EX_PRO_MODE".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 3) ret = True except Exception as err_msg: print("Failed to send param value message 3: %s" % (err_msg)) ret = False d = struct.unpack('f', struct.pack('I', 5))[0] try: the_connection.mav.param_value_send( "S_FOCUS_MODE".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 4) ret = True except Exception as err_msg: print("Failed to send param value message 4: %s" % (err_msg)) ret = False p = struct.unpack('f', struct.pack('I', 11))[0] try: the_connection.mav.param_value_send( "S_FOCUS_AREA".encode('ascii'), p, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 5) ret = True except Exception as err_msg: print("Failed to send param value message 5: %s" % (err_msg)) ret = False d = struct.unpack('f', struct.pack('I', 675))[0] try: the_connection.mav.param_value_send( "S_SHUT_SPD".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 6) ret = True except Exception as err_msg: print("Failed to send param value message 6: %s" % (err_msg)) ret = False d = struct.unpack('f', struct.pack('I', 76))[0] try: the_connection.mav.param_value_send( "S_WHITE_BAL".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 7) ret = True except Exception as err_msg: print("Failed to send param value message 7: %s" % (err_msg)) ret = False d = struct.unpack('f', struct.pack('I', 7))[0] try: the_connection.mav.param_value_send( "S_STILL_CAP".encode('ascii'), d, mavutil.mavlink.MAV_PARAM_TYPE_UINT32, 8, 8) ret = True except Exception as err_msg: print("Failed to send param value message 8: %s" % (err_msg)) ret = False return ret def mavlink_send_camera_information(self, the_connection): #if self.mavlink10(): vendor_name_nd = np.dtype([('ABB',np.uint8)]) model_name_nd = np.dtype([('BAC',np.uint8)]) vendor_name_list = [65,66,66] model_name_list = [66,65,67] vendor_name = "ABB" model_name = "BAC" # # convert string to ascii list and make numpy array # vn = [] mn = [] j = 0 for j in range(len(model_name)): mn.append(ord(model_name[j])) k = 0 for k in range(len(vendor_name)): vn.append(ord(vendor_name[k])) u8_model_name = np.array(mn, np.uint8) u8_vendor_name = np.array(vn, np.uint8) mn_u8 = u8_model_name.astype(np.uint8) vn_u8 = u8_vendor_name.astype(np.uint8) arr_vendor = [0] * 32 arr_vendor[0] = ord("A") arr_model = [0] * 32 arr_model[0] = ord("C") # "http://10.0.2.51/cam_defs/alpha_cam_new.xml".encode('ascii')) print("\033[33m Sending camera information") try: the_connection.mav.camera_information_send( 100, arr_vendor, arr_model, 0, 0, 0, 0, 0, 0, 0, 391, 1, "http://10.0.2.51/cam_defs".encode('ascii')) ret = True except Exception as err_msg: print("Failed to send camera information message : %s" % (err_msg)) ret = False return ret def mavlink_send_camera_settings(self, the_connection): #if self.mavlink10(): try: the_connection.mav.camera_settings_send( self.time_boot_ms, self.mode_id, # Camera mode self.zoomLevel, # Current zoom level (0.0 to 100.0, NaN if not known)*/ self.focusLevel) ret = True except Exception as err_msg: print("Failed to send camera settings message : %s" % (err_msg)) ret = False return ret def mavlink_send_storage_information(self, the_connection): #if self.mavlink10(): # # This is a byte array of the string # b = bytearray(b'ABB') # # forced uint8 with numpy # b8_numpy = np.array(b, np.uint8) # # ascii string encoded # nm = "storenm" try: u8_model_name = (nm).encode("ascii") except Exception as err_msg: print("\033[32m Failed to SET storage information message : %s " % (err_msg)) print(f" sending storage info {u8_model_name} type {type(u8_model_name)}") try: the_connection.mav.storage_information_send( self.time_boot_ms, self.storage_id, self.storage_count, self.status, self.total_capacity, self.used_capacity, self.available_capacity, self.read_speed, self.write_speed, 1, np.array(u8_model_name,np.uint8), 2) ret = True except Exception as err_msg: print("\033[32m Failed to send storage information message : %s type is %s" % (err_msg,type(u8_model_name))) ret = False return ret def mavlink_send_camera_capture_status(self, the_connection): try: the_connection.mav.camera_capture_status_send( self.time_boot_ms, self.image_status, self.video_status, self.image_interval, self.recording_time_ms, self.available_capacity, self.image_count) ret = True except Exception as err_msg: print("Failed to send camera capture status message : %s" % (err_msg)) ret = False return ret def mavlink_send_video_stream_information(self, the_connection): #if self.mavlink10(): print(" !!! sending the video stream information !!! \n") try: the_connection.mav.video_stream_information_send( self.stream_id, self.count, self.stream_type, self.Vflags, self.framerate, self.Vresolution_h, self.Vresolution_v, self.bitrate, self.rotation, self.hfov, #self.videoname, (self.videoname).encode('ascii'), (self.video_uri).encode('ascii')) ret = True except Exception as err_msg: print("Failed to send video stream information message : %s" % (err_msg)) ret = False return ret def mavlink_send_camera_image_captured(self, the_connection): #if self.mavlink10(): b = bytearray(b'[2,3,4,5]') print(f"sending cam image cap {self.time_boot_ms}") try: the_connection.mav.camera_image_captured_send( self.time_boot_ms, self.time_utc, self.camera_id, self.lat, self.lon, self.alt, self.relative_alt, b, self.image_index, self.capture_result, self.file_url) ret = True except Exception as err_msg: print("Failed to send camera image captured message : %s" % (err_msg)) ret = False return ret def mavlink_send_camera_feedback(self, the_connection): #if self.mavlink10(): print("\033[32m sending camera feedback") try: the_connection.mav.camera_feedback_send( self.time_usec, the_connection.target_system, self.cam_idx, self.img_idx, self.lat, self.lng, self.alt_msl, self.alt_rel, self.roll, self.pitch, self.yaw, self.foc_len, self.CFflags) ret = True print("\033[36m success sending camera feedback") except Exception as err_msg: print("Failed to send camera feedback message : %s" % (err_msg)) ret = False return ret # check with this function the order in python !!!!!!!! # def mavlink_send_param_ext_ack(self, the_connection, val, status_code, tag ): print("\033[38m acking the ext parameter iso") d = str(val) try: the_connection.mav.param_ext_ack_send( tag.encode('ascii'), d, mavdefs.MAV_PARAM_EXT_TYPE_UINT32, status_code) ret = True except Exception as err_msg: print("Failed to send param value message 1: %s" % (err_msg)) ret = False def writeParamSetFromMavLink( self, msgString, mavObj, dataRcv, the_connection ): # must be EXACT tag match #patternISO = re.compile(r"\bS_ISO\b") #patternAper = re.compile(r"\bS_APERTURE\b") #patternExPro = re.compile(r"\bS_EX_PRO_MODE\b") #patternFocus = re.compile(r"\bS_FOCUS_MODE\b") #patternFocA = re.compile(r"\bS_FOCUS_AREA\b") #patternShSp = re.compile(r"\bS_SHUT_SPD\b") #patternWhiBal = re.compile(r"S_WHITE_BAL") #patternStCa = re.compile(r"\bS_STILL_CAP\b") if (len(msgString) == 0): print("zero length tag passed") return False if not (msgString.find("S_ISO") == -1): #if (re.search(patternISO, msgString.upper())==True): print(f"saw sonISO with {dataRcv}") if (mavObj.setMavIsoModeData( dataRcv )==True): print(f"setMavIsoModeData sonISO with {dataRcv}") return (self.mavlink_send_param_value_iso( the_connection, dataRcv )) elif not (msgString.find("S_APERTURE") == -1): #elif (re.search(patternAper, msgString.upper())==True): if (mavObj.setMavApertureData( dataRcv )==True): return (self.mavlink_send_param_value_aper( the_connection, dataRcv )) elif not (msgString.find("S_EX_PRO_MODE") == -1): #elif (re.search(patternExPro, msgString.upper())==True): if (mavObj.setMavExProData( dataRcv )==True): return (self.mavlink_send_param_value_expro( the_connection, dataRcv )) elif not (msgString.find("S_FOCUS_AREA") == -1): #elif (re.search(patternFocA, msgString.upper())==True): if (mavObj.setMavFocusAreaData( dataRcv )==True): return (self.mavlink_send_param_value_focus_area( the_connection, dataRcv )) elif not (msgString.find("S_FOCUS_MODE") == -1): #elif (re.search(patternFocus, msgString.upper())==True): if (mavObj.setMavFocusData( dataRcv )==True): return (self.mavlink_send_param_value_focus( the_connection, dataRcv )) elif not (msgString.find("S_SHUT_SPD") == -1): #elif (re.search(patternShSp, msgString.upper())==True): if (mavObj.setMavShutterData( dataRcv )==True): return (self.mavlink_send_param_value_shut_spd( the_connection, dataRcv )) elif not (msgString.find("S_WHITE_BAL") == -1): #elif (re.search(patternWhiBal, msgString.upper())==True): if (mavObj.setMavWhiteBalData( dataRcv )==True): return (self.mavlink_send_param_value_white_bal( the_connection, dataRcv )) elif not (msgString.find("S_STILL_CAP") == -1): #elif (re.search(patternStCa, msgString.upper())==True): if (mavObj.setMavStillCapModeData( dataRcv )==True): return (self.mavlink_send_param_value_still_cap( the_connection, dataRcv )) else: print("unsupported variable name %s to val=%d :: NOT SET "%(msgString,dataRcv)) return False def readParamSetFromMavLink( self, msgString, mavObj, the_connection ): # must be EXACT tag match #patternISO = re.compile(r"\bS_ISO\b") #patternAper = re.compile(r"\bS_APERTURE\b") #patternExPro = re.compile(r"\bS_EX_PRO_MODE\b") #patternFocus = re.compile(r"\bS_FOCUS_MODE\b") #patternFocA = re.compile(r"\bS_FOCUS_AREA\b") #patternShSp = re.compile(r"\bS_SHUT_SPD\b") #patternWhiBal = re.compile(r"S_WHITE_BAL") #patternStCa = re.compile(r"\bS_STILL_CAP\b") v = 0 p = 0 r = False if (len(msgString) == 0): print("zero length tag passed") return False if not (msgString.find("S_ISO") == -1): #if (re.search(patternISO, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamIso # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavIsoModeData( ) if (r == True): return ( self.mavlink_send_param_value_iso( the_connection, v ) ) else: return False elif not (msgString.find("S_APERTURE") == -1): #elif (re.search(patternAper, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamAperture # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavApertureData( ) if (r == True): return ( self.mavlink_send_param_value_aper( the_connection, v ) ) else: return False elif not (msgString.find("S_EX_PRO_MODE") == -1): #elif (re.search(patternExPro, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamExPro # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavExProData( ) if (r == True): return ( self.mavlink_send_param_value_expro( the_connection, v ) ) else: return False elif not (msgString.find("S_FOCUS_AREA") == -1): #elif (re.search(patternFocA, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamFocusArea # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavFocusAreaData( ) if (r == True): return ( self.mavlink_send_param_value_focus_area( the_connection, v ) ) else: return False elif not (msgString.find("S_FOCUS_MODE") == -1): #elif (re.search(patternFocus, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamFocus # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavFocusData( ) if (r == True): return ( self.mavlink_send_param_value_focus( the_connection, v ) ) else: return False elif not (msgString.find("S_SHUT_SPD") == -1): #elif (re.search(patternShSp, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamShutSpd # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavShutterData( ) if (r == True): return ( self.mavlink_send_param_value_shut_spd( the_connection, v ) ) else: return False elif not (msgString.find("S_WHITE_BAL") == -1): #elif (re.search(patternWhiBal, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamWhiteBala # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavWhiteBalData( ) if (r == True): return ( self.mavlink_send_param_value_white_bal( the_connection, v ) ) else: return False elif not (msgString.find("S_STILL_CAP") == -1): #elif (re.search(patternStCa, msgString.upper())==True): with mavObj.mav_req_all_param.get_lock(): mavObj.mav_req_all_param.value |= mavlinkSonyCamWriteVals.ParamStillCap # >>> set the bit to enable full read of parameter v, p, r = mavObj.getMavStillCapModeData( ) if (r == True): return ( self.mavlink_send_param_value_still_cap( the_connection, v ) ) else: return False else: print("unsupported variable name %s :: NOT SET "%(msgString)) return False def writeParamExtSetFromMavLink( self, msgString, mavObj, dataRcv, the_connection ): # must be EXACT tag match #patternISO = re.compile(r"\bS_ISO\b") #patternAper = re.compile(r"\bS_APERTURE\b") #patternExPro = re.compile(r"\bS_EX_PRO_MODE\b") #patternFocus = re.compile(r"\bS_FOCUS_MODE\b") #patternFocA = re.compile(r"\bS_FOCUS_AREA\b") #patternShSp = re.compile(r"\bS_SHUT_SPD\b") #patternWhiBal = re.compile(r"S_WHITE_BAL") #patternStCa = re.compile(r"\bS_STILL_CAP\b") ret = False if (len(msgString) == 0): print("zero length tag passed") return False if not (msgString.find("S_ISO") == -1): #if (re.search(patternISO, msgString.upper())==True): if ((mavObj.setMavIsoModeData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_ISO" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_ISO" ) elif not (msgString.find("S_APERTURE") == -1): #elif (re.search(patternAper, msgString.upper())==True): if ((mavObj.setMavApertureData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_APERTURE" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_APERTURE" ) elif not (msgString.find("S_EX_PRO_MODE") == -1): #elif (re.search(patternExPro, msgString.upper())==True): if ((mavObj.setMavExProData( dataRcv )) == True): self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_EX_PRO_MODE" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_EX_PRO_MODE" ) elif not (msgString.find("S_FOCUS_AREA") == -1): #elif (re.search(patternFocA, msgString.upper())==True): if ((mavObj.setMavFocusAreaData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_FOCUS_AREA" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_FOCUS_AREA" ) elif not (msgString.find("S_FOCUS_MODE") == -1): #elif (re.search(patternFocus, msgString.upper())==True): if ((mavObj.setMavFocusData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_FOCUS_MODE" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_FOCUS_MODE" ) elif not (msgString.find("S_SHUT_SPD") == -1): #elif (re.search(patternShSp, msgString.upper())==True): if ((mavObj.setMavShutterData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_SHUT_SPD" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_SHUT_SPD" ) elif not (msgString.find("S_WHITE_BAL") == -1): #elif (re.search(patternWhiBal, msgString.upper())==True): if ((mavObj.setMavWhiteBalData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_WHITE_BAL" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_WHITE_BAL" ) elif not (msgString.find("S_STILL_CAP") == -1): #elif (re.search(patternStCa, msgString.upper())==True): if ((mavObj.setMavStillCapModeData( dataRcv )) == True): ret = self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_ACCEPTED, "S_STILL_CAP" ) else: self.mavlink_send_param_ext_ack( the_connection, dataRcv, mavutil.mavlink.PARAM_ACK_FAILED, "S_STILL_CAP" ) else: print("unsupported variable name %s to val=%d :: NOT SET "%(msgString,dataRcv)) return False return ret def readParamExtSetFromMavLink( self, msgString, mavObj, the_connection ): # must be EXACT tag match #patternISO = re.compile(r"\bS_ISO\b") #patternAper = re.compile(r"\bS_APERTURE\b") #patternExPro = re.compile(r"\bS_EX_PRO_MODE\b") #patternFocus = re.compile(r"\bS_FOCUS_MODE\b") #patternFocA = re.compile(r"\bS_FOCUS_AREA\b") #patternShSp = re.compile(r"\bS_SHUT_SPD\b") #patternWhiBal = re.compile(r"S_WHITE_BAL") #patternStCa = re.compile(r"\bS_STILL_CAP\b") v = 0 p = 0 r = False if (len(msgString) == 0): print("zero length tag passed") return False if not (msgString.find("S_ISO") == -1): #if (re.search(patternISO, msgString.upper())==True): v, p, r = mavObj.getMavIsoModeData( ) if (r == True): if ( self.mavlink_send_param_ext_value_iso( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamIso # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_APERTURE") == -1): #elif (re.search(patternAper, msgString.upper())==True): v, p, r = mavObj.getMavApertureData( ) if (r == True): if ( self.mavlink_send_param_ext_value_aper( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamAperture # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_EX_PRO_MODE") == -1): #elif (re.search(patternExPro, msgString.upper())==True): v, p, r = mavObj.getMavExProData( ) if (r == True): if ( self.mavlink_send_param_ext_value_expro( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamExPro # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_FOCUS_AREA") == -1): #elif (re.search(patternFocA, msgString.upper())==True): v, p, r = mavObj.getMavFocusAreaData( ) if (r == True): if ( self.mavlink_send_param_ext_value_focus_area( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamFocusArea # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_FOCUS_MODE") == -1): #elif (re.search(patternFocus, msgString.upper())==True): v, p, r = mavObj.getMavFocusData( ) if (r == True): if ( self.mavlink_send_param_ext_value_focus( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamFocus # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_SHUT_SPD") == -1): #elif (re.search(patternShSp, msgString.upper())==True): v, p, r = mavObj.getMavShutterData( ) if (r == True): if ( self.mavlink_send_param_ext_value_shut_spd( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamShutSpd # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_WHITE_BAL") == -1): #elif (re.search(patternWhiBal, msgString.upper())==True): v, p, r = mavObj.getMavWhiteBalData( ) if (r == True): if ( self.mavlink_send_param_ext_value_white_bal( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamWhiteBala # >>> set the bit to enable full read of parameter return r return False elif not (msgString.find("S_STILL_CAP") == -1): #elif (re.search(patternStCa, msgString.upper())==True): v, p, r = mavObj.getMavStillCapModeData( ) if (r == True): if ( self.mavlink_send_param_ext_value_still_cap( the_connection, v ) == True ): with mavObj.mav_ext_req_all_param.get_lock(): mavObj.mav_ext_req_all_param.value |= mavObj.ParamStillCap # >>> set the bit to enable full read of parameter return r return False else: print("unsupported variable name %s to val=%d :: NOT SET "%(msgString,dataRcv)) return False # process the incoming messages received # def process_messages_from_connection(self, the_connection, sharedObj): #""" #This runs continuously. The mavutil.recv_match() function will call mavutil.post_message() #any time a new message is received, and will notify all functions in the master.message_hooks list. #""" loop = 5 while loop >= 1: #while True: print("im receiving.............") #time.sleep(0.05) #self.update_uptime_label( ) #self.update_utc_label( ) # # wait heartbeat (only the GCS does this ) # m = the_connection.recv_match(type="HEARTBEAT", blocking=True, timeout=5) # # you can also use type lists like this # type=['COMMAND_LONG,RC_CHANNELS'] # #msg = the_connection.recv_match(blocking=True, timeout=5) msg = the_connection.recv_match(blocking=True, timeout=1) if (msg is None): # timeout with nothing just return return if ( the_connection.target_system == msg.get_srcSystem() ): # check this and eliminate spurious messages if needed print(f"data read {msg.get_type()}") print(f"connection {the_connection.target_system} == {msg.get_srcSystem()}") last_timestamp = msg._timestamp # # These are test messages to check the receive end !!!! # #self.mavlink_send_camera_feedback( the_connection ) #self.mavlink_send_camera_information(the_connection) #self.mavlink_send_storage_information(the_connection) #self.mavlink_send_camera_capture_status(the_connection) #print(f" video stream returned {self.mavlink_send_video_stream_information(the_connection)}") #self.mavlink_send_camera_image_captured(the_connection) #the_connection.mav.camera_feedback_send( 1000, 1, 1, 22, 21, 10, 30, 21, 2, 3, 5, 2, 3) #the_connection.mav.gps_raw_int_send( 1000, self.g_count, 77, 66, 76, 3, 1, 2, 3, 5) #the_connection.mav.vibration_send( 1000, 1, 1, 22, 21, 10, 30 ) #self.mavlink_send_camera_information(the_connection) #self.mavlink_send_param_value(the_connection) #print("FTP request for XML file .... I'm sending it as my payload") #try: # f = open(self.CAM_XML_FILE,'r') # #payload = f.read() not raw read but as bytes below # lab = np.fromfile(f, dtype=np.uint8) # f.close() #except Exception as e: # print(f" XML file read exception {e}") #self.mavlink_do_ftp_send( the_connection, self.NETWORK_ID, lab) self.g_count = self.g_count + 1 if not msg: print("\033[31m no msg ! \033[0m") return if msg.get_type() == "BAD_DATA": self.ACK_ERROR = self.GOT_BAD self.errRCV_COMMAND = 0 self.errRPM2 = 0 if mavutil.all_printable(msg.data): sys.stdout.write(msg.data) sys.stdout.flush() elif msg.get_type() == 'PARAM_REQUEST_LIST': # this is a dummy message to reply immediately for now # # out for now update sent right away self.mavlink_send_param_value(the_connection) # with sharedObj.mav_req_all_param.get_lock(): sharedObj.mav_req_all_param.value = mavlinkSonyCamWriteVals.MAV_REQ_ALL_PARAM print("\033[35m PARAM_REQUEST_LIST was sent - shared object set to %d" % (sharedObj.mav_req_all_param.value)) # ===== TRAP ====== #exit(99) elif msg.get_type() == 'PARAM_EXT_REQUEST_LIST': # # with sharedObj.mav_ext_req_all_param.get_lock(): sharedObj.mav_ext_req_all_param.value = mavlinkSonyCamWriteVals.MAV_REQ_ALL_PARAM print("\033[35m PARAM_EXT_REQUEST_LIST was sent - shared object set to %d" % (sharedObj.mav_ext_req_all_param.value)) # ===== TRAP ====== #exit(99) elif msg.get_type() == 'PARAM_SET': # # for testing...... self.mavlink_send_ext_param_value(the_connection) # # # value is sent as a float but its an integer, so unpack the float read as an integer # ref:- https://gist.github.com/AlexEshoo/d3edc53129ed010b0a5b693b88c7e0b5 # m = struct.unpack('I', struct.pack('f', msg.param_value))[0] ee = self.mav_param_type_conv( msg.param_type, msg.param_value ) print(f"\033[36m Values mavlink :: {m} from func {ee}") if ( self.writeParamSetFromMavLink( msg.param_id, sharedObj, ee, the_connection ) == True ): print(f"\033[33m PARAM_SET was sent for {msg.param_id} val {ee} type {msg.param_type} really sent {m} \033[0m" ) else: print("\033[31m PARAM_SET write fail for %s :: %d type %d \033[0m"%( msg.param_id, ee, msg.param_type )) # ===== TRAP ===== #exit(97) elif msg.get_type() == 'PARAM_REQUEST_READ': # if ( self.readParamSetFromMavLink( msg.param_id, sharedObj, the_connection )==True): print(f"\033[34m Success reading param {msg.param_id} \033[0m") else: print(f"\033[31;46m Error reading param {msg.param_id} \033[0m") # ===== TRAP ===== #exit(96) elif msg.get_type() == 'PARAM_EXT_REQUEST_READ': # if ( self.readParamExtSetFromMavLink( msg.param_id, sharedObj, the_connection )==True): print(f"\033[32m Sucess reading EXT Param {msg.param_id} \033[0m") else: print(f"\033[31;43m Error sending param {msg.param_id} \033[0m") # ===== TRAP ===== #exit(96) elif msg.get_type() == 'PARAM_EXT_SET': # # self.mavlink_send_param_value(the_connection) there are two different data types from various senders # converted = True try: valueSet = int(msg.param_value) except Exception as err_msg: print(f"\033[31m PARAM_EXT_SET :: Error converting type {err_msg} \033[0m") try: valueSetActual = msg.param_value valueSet = int(valueSetActual.decode('ascii')) except Exception as err_msg: print(f"\033[31m PARAM_EXT_SET :: Error converting type {err_msg} it says {msg.param_value} \033[0m") converted = False if (( self.writeParamExtSetFromMavLink( msg.param_id, sharedObj, valueSet ) == True ) and ( converted == True) ): print("\033[35m PARAM_EXT_SET :: was sent for %s :: %d \033[0m"%( msg.param_id, valueSet )) ## =======> send_ext_ack else: print("\033[31m PARAM_EXT_SET :: write fail for %s :: %d \033[0m"%( msg.param_id, valueSet)) # ===== TRAP ===== #exit(95) elif msg.get_type() == 'PARAM_VALUE': print(f"Recieved a param value for :- {msg.param_id} = {msg.param_value}") elif msg.get_type() == 'RC_CHANNELS': print("RC Channel message (system %u component %u)\n" % (the_connection.target_system, the_connection.target_component)) elif msg.get_type() == 'COMMAND_LONG': print("!!!!!! Long message received (system %u component %u)\n" % (the_connection.target_system, the_connection.target_component)) print("in cmd long ... ACK RES %s %u \n" % (self.ACK_RESULT,mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_INFORMATION)) print("Command %u p1 %u p2 %u p3 %u p4 %u \n" % (msg.command, msg.param1, msg.param2, msg.param3, msg.param4)) print("p5 %u p6 %u p7 %u \n" % (msg.param5, msg.param6, msg.param7)) # print(msg.get_payload()) # print(msg.get_msgbuf()) # print(msg.get_fieldnames()) # print(msg.get_type()) # # print the message recieved in json # print(msg.to_dict()) if not (self.ACK_RESULT == mavutil.mavlink.MAV_RESULT_ACCEPTED): self.RCV_COMMAND = int(msg.command) print(f"\033[35m IN LOOP :: self ACK RES {self.ACK_RESULT} RCV {self.RCV_COMMAND} == {mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE}") if (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE): self.RPM2 = int(msg.param1) print(f"Is it here {self.RPM2} == {self.CAMERA_INFORMATION}") if (self.RPM2 == self.CAMERA_INFORMATION): #camera_information self.type_of_msg = 6500 print("\033[34m >>>>>> camera information \033[36m >>>>>>>>>>>>>>>>>>>>>>") self.mavlink_send_camera_information(the_connection) elif (self.RPM2 == self.CAMERA_SETTINGS): #camera_settings self.type_of_msg = 6501 elif (self.RPM2 == self.STORAGE_INFORMATION): #storage information self.type_of_msg = 6502 elif (self.RPM2 == self.CAMERA_CAPTURE_STATUS): #camera capture status self.type_of_msg = 6503 elif (self.RPM2 == mavutil.mavlink.MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED): #retrieve lost images self.type_of_msg = 6504 self.Got_Param1 = int(msg.param2) elif (self.RPM2 == 269): #video stream self.type_of_msg = 6505 else: self.type_of_msg = 0 print(f"camera info received {self.RPM2}") elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_INFORMATION): print("request camera Info OLD MESSAGE.....") # # Send camera information # # test here..... self.mavlink_send_camera_information(the_connection) if (msg.param1 == 1): self.type_of_msg = mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_INFORMATION print("\033[32m =========== !! sending to QGround Camera Information !! ==========\033[0m ") self.mavlink_send_camera_information(the_connection) else: print("\033[33m =========== !! not sending to QGround Camera Information !! ==========\033[0m ") elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_REQUEST_VIDEO_STREAM_INFORMATION): print("request video stream Info OLD MESSAGE.....") self.type_of_msg = mavutil.mavlink.MAV_CMD_REQUEST_VIDEO_STREAM_INFORMATION print("=========== !! send to QGround VideoStream !! ==========") self.mavlink_send_video_stream_information(the_connection) elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_SETTINGS): print("request camera settings Info OLD MESSAGE.....") self.type_of_msg = mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_SETTINGS print("\033[35m =========== !! sending to QGround Camera settings !! ========== \033[0m") self.mavlink_send_camera_settings(the_connection) elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_CAPTURE_STATUS): print("request camera capture status Info OLD MESSAGE.....") self.type_of_msg = mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_CAPTURE_STATUS print("\033[36m =========== !! send to QGround Camera capture status !! ========== \033[0m") self.mavlink_send_camera_capture_status(the_connection) elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_REQUEST_STORAGE_INFORMATION): print("request storage info Info OLD MESSAGE.....") self.type_of_msg = mavutil.mavlink.MAV_CMD_REQUEST_STORAGE_INFORMATION print("\033[34m =========== !! send to QGround Camera storage_info !! ========== \033[0m") self.mavlink_send_storage_information(the_connection) elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_SET_RELAY): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_SET_RELAY print(f"\033 [31m >>>>> Got a message to set the RelayNo {msg.param1} to state {msg.param2}") self.raspberry_pi3_set_relay(self, msg.param1, msg.param2) self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_VIDEO_START_CAPTURE): self.type_of_msg = mavutil.mavlink.MAV_CMD_VIDEO_START_CAPTURE self.Got_Param1 = msg.param1 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_VIDEO_STOP_CAPTURE): self.type_of_msg = mavutil.mavlink.MAV_CMD_VIDEO_START_CAPTURE self.Got_Param1 = msg.param1 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_IMAGE_START_CAPTURE): self.type_of_msg = mavutil.mavlink.MAV_CMD_IMAGE_START_CAPTURE self.Got_Param1 = msg.param2 self.Got_Param2 = msg.param3 self.Got_Param3 = msg.param4 sharedObj.take_continuos = True elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_IMAGE_STOP_CAPTURE): self.type_of_msg = mavutil.mavlink.MAV_CMD_IMAGE_STOP_CAPTURE self.Got_Param1 = msg.param3 self.Got_Param2 = msg.param4 sharedObj.take_continuos = False elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_VIDEO_START_STREAMING): self.type_of_msg = mavutil.mavlink.MAV_CMD_VIDEO_START_STREAMING self.Got_Param1 = msg.param1 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_VIDEO_STOP_STREAMING): self.type_of_msg = mavutil.mavlink.MAV_CMD_VIDEO_STOP_STREAMING self.Got_Param1 = msg.param1 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_SET_CAMERA_MODE): self.type_of_msg = mavutil.mavlink.MAV_CMD_SET_CAMERA_MODE self.Got_Param1 = msg.param2 elif (self.RCV_COMMAND == mavdefs.MAV_CMD_SET_CAMERA_ZOOM): self.type_of_msg = mavdefs.MAV_CMD_SET_CAMERA_ZOOM self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 elif (self.RCV_COMMAND == mavdefs.MAV_CMD_SET_CAMERA_FOCUS): self.type_of_msg = mavdefs.MAV_CMD_SET_CAMERA_FOCUS self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONFIGURE): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONFIGURE self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 self.Got_Param4 = msg.param4 self.Got_Param5 = msg.param5 self.Got_Param6 = msg.param6 self.Got_Param7 = msg.param7 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONTROL): # # Taking a picture is hard coded to here as it needs no delay # self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONTROL print(f"\033[33m DO DIGICAM CONTROL {msg.param5} {msg.param7}") if ((int(msg.param5) == 1) and (int(msg.param7) == 0)): #fastGlobals.take_picture = 1 sharedObj.take_photo.value = True print("asked to take a photo ....... set it to 1") #time.sleep(10) self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 self.Got_Param4 = msg.param4 self.Got_Param5 = msg.param5 self.Got_Param6 = msg.param6 self.Got_Param7 = msg.param7 print(f"\033[36m DO DIGICAM CONTROL COMPLETED \033[0m {msg.param5} {msg.param7} ") #time.sleep(10) #exit(100) elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_CONTROL_VIDEO): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_CONTROL_VIDEO self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 self.Got_Param4 = msg.param4 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_RESET_CAMERA_SETTINGS): self.type_of_msg = mavutil.mavlink.MAV_CMD_RESET_CAMERA_SETTINGS self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 sharedObj.reset_cam = True elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_MOUNT_CONTROL_QUAT): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_MOUNT_CONTROL_QUAT self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 self.Got_Param4 = msg.param4 #elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW): # self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW # self.Got_Param1 = msg.param1 # self.Got_Param2 = msg.param2 # self.Got_Param3 = msg.param3 # self.Got_Param4 = msg.param4 # self.Got_Param5 = msg.param5 # self.Got_Param6 = msg.param6 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_TRIGGER_CONTROL): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_TRIGGER_CONTROL self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 elif (self.RCV_COMMAND == 2004): # MAV_CMD_CAMERA_TRACK_POINT=2004 self.type_of_msg = 2004; self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 elif (self.RCV_COMMAND == 2005): # MAV_CMD_CAMERA_TRACK_RECTANGLE=2005 self.type_of_msg = 2005; self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 self.Got_Param3 = msg.param3 elif (self.RCV_COMMAND == 2010): # MAV_CMD_CAMERA_STOP_TRACKING=2010 self.type_of_msg = 2010; elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_STORAGE_FORMAT): self.type_of_msg = mavutil.mavlink.MAV_CMD_STORAGE_FORMAT self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_DO_SET_SERVO): self.type_of_msg = mavutil.mavlink.MAV_CMD_DO_SET_SERVO self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 print("\033[32m saw the relay command come in") elif (self.RCV_COMMAND == mavutil.mavlink.MAVLINK_MSG_ID_BATTERY_STATUS): self.type_of_msg = mavutil.mavlink.MAVLINK_MSG_ID_BATTERY_STATUS self.Got_Param1 = msg.param1 self.Got_Param2 = msg.param2 print("\033[32m saw the battery status request come in") elif (self.RCV_COMMAND == mavutil.mavlink.MAV_CMD_PREFLIGHT_STORAGE): print(f"\033[33m Asks for storage params paramStorage={msg.param1} missionStorage={msg.param2} \033[0m") elif (self.RCV_COMMAND == 42428): print(f"\033[37m Command 42428 was sent not sure what im meant to do..... \033[0m") else: print(f"got this id {self.RCV_COMMAND} {msg.command}") self.RPM2 = 0 self.type_of_msg = self.RCV_COMMAND self.ACK_RESULT = mavutil.mavlink.MAV_RESULT_ACCEPTED print("\033[36m >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ACK RES %d %d"%(self.ACK_RESULT,mavutil.mavlink.MAV_RESULT_ACCEPTED)) print("\033[31m") else: self.ACK_ERROR = self.GOT_ERROR self.errRCV_COMMAND = msg.command self.errRPM2 = msg.param1 print(f"Error ACK message send for multiple request @ cmd :: {self.errRCV_COMMAND} rpm :: {self.errRPM2}") elif msg.get_type() == 'CAMERA_IMAGE_CAPTURED': print("Cam Cap message received (system %u component %u)\n" % (the_connection.target_system, the_connection.target_component)) print("lat %u lon %u alt %u\n" % (msg.lat, msg.lon, msg.alt)) print("URL %u)\n" % (msg.file_url)) elif msg.get_type() == 'GPS_RAW_INT': the_connection.mav.gps_raw_int_send( 1000, 1, 22, 21, 1, 3, 1, 2, 3, 5) elif msg.get_type() == 'CAMERA_FEEDBACK': print("Camera Feedback request was made") #the_connection.mav.camera_feedback_send( 1000, 1, 1, 22, 21, 10, 30, 21, 2, 3, 5, 2, 3) elif msg.get_type() == 'FILE_TRANSFER_PROTOCOL': print("FTP request for XML file .... I'm sending it as my payloads in chunks of 251 bytes") lab = [] try: f = open(self.CAM_XML_FILE,'r') #payload = f.read() not raw read but as bytes below lab = np.fromfile(f, dtype=np.uint8) f.close() except Exception as e: print(f" XML file read exception {e}") self.mavlink_do_ftp_send( the_connection, self.NETWORK_ID, lab) elif msg.get_type() == 'REQUEST_DATA_STREAM': print("REQUEST DATA STREAM :: start %u id %u req_rte %u\n" % (msg.start_stop, msg.req_stream_id, msg.req_message_rate)) elif msg.get_type() == 'STATUSTEXT': print("STATUSTEXT :: text %s " % (msg.text)) elif msg.get_type() == 'HEARTBEAT': print("HEARTBEAT :: src %s type %s auto %s sys %s" % (msg.get_srcSystem(), msg.type,msg.autopilot,msg.system_status)) else: print(f"unsupported command :: {msg.get_type()}") #time.sleep(0.05) loop = loop - 1 def mavlink_send_ack_command(self, the_connection, cmd, rpm2, pro, res): if (self.mavlink20(the_connection) == True): print(f"\033[31m sending an ACK {pro}") try: the_connection.mav.command_ack_send( int(cmd), # command int(res), # result int(pro), # progress int(rpm2), # result_param2 the_connection.target_system, # target_system the_connection.target_component) # target_component print(f"ACK sent {rpm2} {res}") ret = True except Exception as err_msg: print("Failed 1st ACK message : %s" % (err_msg)) try: the_connection.mav.command_ack_send( int(cmd), # command int(res)) # result print(f"ACK sent {rpm2} {res}") ret = True except Exception as err_msg: print("Failed 2nd ACK message : %s" % (err_msg)) ret = False return ret elif (self.mavlink10(the_connection) == True): print(f"\033[31m sending an ACK {pro}") try: the_connection.mav.command_ack_send( int(cmd), # command int(res)) # result print(f"ACK sent {rpm2} {res}") ret = True except Exception as err_msg: print("Failed 1st ACK message : %s" % (err_msg)) try: the_connection.mav.command_ack_send( int(cmd), # command int(res), # result int(pro), # progress int(rpm2), # result_param2 the_connection.target_system, # target_system the_connection.target_component) # target_component print(f"ACK sent {rpm2} {res}") ret = True except Exception as err_msg: print("Failed 2nd ACK message : %s" % (err_msg)) ret = False return ret # # ============================================================= multi-process threads ===================================================================== # Camera Action Routines # Mavlink Response Signals # async def doAlphaCameraExpro( mySonyCam, mav2SonyVals, expro, tm_upd_disable=False, time_delta = 1000 ): with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_EX_PRO p = multiprocessing.current_process() print ('Starting Exposure Program :', p.name, p.pid) # # initialise general program control flags # success = False timenow = 0 # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.setSonyCamExProData( expro, mav2SonyVals ) # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - expro.timestamp.value) > time_delta): if (mySonyCam.getSonyCamExProData( expro )==True): with expro.timestamp.get_lock(): expro.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE #print(f"\033[36m Time Delta occurred {timenow} {expro.timestamp.value}") #else: #print(f"\033[34m No time diff {timenow} {expro.timestamp.value}") print ('Exiting Exposure Program :', multiprocessing.current_process().name) async def sendMavExpro( mySonyCam, expro, ConnID ): p = multiprocessing.current_process() print ('Starting Exposure Program:', p.name, p.pid) success = mySonyCam.sendMavlinkMessageForParamObject( expro, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( expro, ConnID ) print ('Exiting Exposure Program :', multiprocessing.current_process().name) async def doAlphaCameraAperture( mySonyCam, mav2SonyVals, aper, tm_upd_disable=False, time_delta = 1000 ): with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_APER p = multiprocessing.current_process() print ('Starting Aperture :', p.name, p.pid) # # initialise general program control flags # success = False timenow = 0 # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.setSonyCamApertureData( aper, mav2SonyVals ) # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - aper.timestamp.value) > time_delta): if (mySonyCam.getSonyApertureData( aper )==True): with aper.timestamp.get_lock(): aper.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE print ('Exiting Aperture :', multiprocessing.current_process().name) async def sendMavAper( mySonyCam, aper, ConnID ): p = multiprocessing.current_process() print ('Starting Mavlink Aperture :', p.name, p.pid) success = mySonyCam.sendMavlinkMessageForParamObject( aper, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( aper, ConnID ) print ('Exiting Mavlink Aperture :', multiprocessing.current_process().name) async def doAlphaCameraFocusData( mySonyCam, mav2SonyVals, focusdata, focusarea, tm_upd_disable=False, time_delta = 1000 ): with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_FOCUS p = multiprocessing.current_process() print ('Starting Focus :', p.name, p.pid) # # initialise general program control flags # success = False timenow = 0 # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.setSonyCamFocusData( focusdata, mav2SonyVals ) success = mySonyCam.setSonyCamFocusAreaData( focusarea, mav2SonyVals ) # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - focusdata.timestamp.value) > time_delta): if (mySonyCam.getSonyCamFocusData( focusdata )==True): with focusdata.timestamp.get_lock(): focusdata.timestamp.value = timenow if ((timenow - focusarea.timestamp.value) > time_delta): if (mySonyCam.getSonyCamFocusAreaData( focusarea )==True): with focusarea.timestamp.get_lock(): focusarea.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE print ('Exiting Focus :', multiprocessing.current_process().name) async def sendMavFocusData( mySonyCam, focusdata, focusarea, ConnID ): p = multiprocessing.current_process() print ('Starting Mavlink Focus Data :', p.name, p.pid) # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.sendMavlinkMessageForParamObject( focusdata, ConnID ) success = mySonyCam.sendMavlinkMessageForParamObject( focusarea, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( focusdata, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( focusarea, ConnID ) print ('Exiting Mavlink Focus Data :', multiprocessing.current_process().name) async def doAlphaCameraIso( mySonyCam, mav2SonyVals, iso, retries=3, tm_upd_disable=False, time_delta = 1000 ): p = multiprocessing.current_process() print ('Starting ISO set :', p.name, p.pid) with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_ISO # # initialise general program control flags # success = False timenow = 0 print("\033[33m ================== ISO :: in manage function ======================== \033[0m") # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # retry = 0 while (retry < retries): if (mySonyCam.setSonyCamISOData( iso, mav2SonyVals ) == True): print("\033[36m sony cam iso data success \033[0m") break else: print("\033[31m sony cam iso data write failure \033[0m") time.sleep(1) retry += 1 else: print("\033[31;43m having probs !!! gonna reset it \033[0m") reset_usb_camlink() # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - iso.timestamp.value) > time_delta): if (mySonyCam.getSonyCamISOData( iso )==True): print(f"\033[36;45m ISO timeupdate required @ {iso.timestamp.value} {timenow}") with iso.timestamp.get_lock(): iso.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE print ('Exiting ISO Set :', multiprocessing.current_process().name) async def sendMavIso( mySonyCam, iso, ConnID ): p = multiprocessing.current_process() print ('Starting ISO :', p.name, p.pid) # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.sendMavlinkMessageForParamObject( iso, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( iso, ConnID ) print ('Exiting ISO :', multiprocessing.current_process().name) async def doAlphaCameraShutSpd( mySonyCam, mav2SonyVals, shut_sp, tm_upd_disable=False, time_delta = 1000 ): p = multiprocessing.current_process() print ('Starting Shutter Speed :', p.name, p.pid) with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_SS # # initialise general program control flags # success = False timenow = 0 # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.setSonyCamShutSpdData( shut_sp, mav2SonyVals ) # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - shut_sp.timestamp.value) > time_delta): if (mySonyCam.getSonyCamShutSpdData( shut_sp )==True): with shut_sp.timestamp.get_lock(): shut_sp.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE print ('Exiting Shutter Speed :', multiprocessing.current_process().name) async def sendMavShutSpd( mySonyCam, shut_sp, ConnID ): p = multiprocessing.current_process() print ('Starting Mavlink Shutter Speed :', p.name, p.pid) # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.sendMavlinkMessageForParamObject( shut_sp, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( shut_sp, ConnID ) print ('Exiting Mavlink Shutter Speed :', multiprocessing.current_process().name) async def doAlphaWhiteBala( mySonyCam, mav2SonyVals, whitebal, tm_upd_disable=False, time_delta = 1000 ): p = multiprocessing.current_process() print ('Starting White Balance :', p.name, p.pid) with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_WB # # initialise general program control flags # success = False timenow = 0 # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.setSonyCamWhiteBalaData( whitebal, mav2SonyVals ) # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - whitebal.timestamp.value) > time_delta): if (mySonyCam.getSonyCamWhiteBalaData( whitebal )==True): with whitebal.timestamp.get_lock(): whitebal.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE print ('Exiting White Balance :', multiprocessing.current_process().name) async def sendMavWhiteBala( mySonyCam, whitebal, ConnID ): p = multiprocessing.current_process() print ('Starting Mavlink White Balance :', p.name, p.pid) success = mySonyCam.sendMavlinkMessageForParamObject( whitebal, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( whitebal, ConnID ) print ('Exiting Mavlink White Balance :', multiprocessing.current_process().name) async def doAlphaCameraStillCap( mySonyCam, mav2SonyVals, stillcap, tm_upd_disable=False, time_delta = 1000 ): # # initialise general program control flags # success = False timenow = 0 with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_SC # use this if you want ot make a daemon proc p = multiprocessing.current_process() print ('Starting Still Capture :', p.name, p.pid) # # # check to see if mavlink wrote something if so write to cam # and update the update flag to get the mavlink send # success = mySonyCam.setSonyCamStillCapModeData( stillcap, mav2SonyVals ) # # Time enabled reading to poll on time_delta # when this data is written the mavlink task # should send it to the GCS via mavlink messages # if not (tm_upd_disable == True): timenow = mySonyCam.my_timestamp() # if ((timenow - stillcap.timestamp.value) > time_delta): if (mySonyCam.getSonyCamStillCapModeData( stillcap )==True): with stillcap.timestamp.get_lock(): stillcap.timestamp.value = timenow with mav2SonyVals.mp_state.get_lock(): mav2SonyVals.mp_state.value = mavlinkSonyCamWriteVals.FUNC_IDLE print ('Exiting Still Capture :', multiprocessing.current_process().name) # -------------------------------- SEQUENTIAL ------------------------------------------------------------------------------ # # These tasks runs sequentially the camera actions and interface back with the scheduler # def manageAlphaCameraExpro( cam, classObj, pvar, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaCameraExpro( cam, classObj, pvar ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_APER print(f"Task1:: Expro") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY # # this task runs sequentially and doesnt set the variables (attributes) of the class passed to it. # def manageAlphaCameraAperture( cam, classObj, pvar, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaCameraAperture( cam, classObj, pvar ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_FOCUS print(f"Task2:: Aperture") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY def manageAlphaCameraFocusData( cam, classObj, pvar, c, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaCameraFocusData( cam, classObj, pvar, c ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_ISO print(f"Task3:: Focus parameters") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY def manageAlphaCameraIso( cam, classObj, pvar, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaCameraIso( cam, classObj, pvar ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_SS print(f"Task4:: Iso") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY def manageAlphaCameraShutSpd( cam, classObj, pvar, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaCameraShutSpd( cam, classObj, pvar ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_WB print(f"Task5:: Shutter Speed") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY def manageAlphaWhiteBala( cam, classObj, pvar, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaWhiteBala( cam, classObj, pvar ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_SC print(f"Task6:: White Balance") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY def manageAlphaCameraStillCap( cam, classObj, pvar, mpc, state_of_task ): state_of_task.value = mavlinkSonyCamWriteVals.STATE_CAM_WRITING doAlphaCameraStillCap( cam, classObj, pvar ) with mpc.get_lock(): mpc.value = mavlinkSonyCamWriteVals.FUNC_EX_PRO print(f"Task7:: Still Capture") # advance to the next routine in the queued sequence with state_of_task.get_lock(): state_of_task.value = mavlinkSonyCamWriteVals.STATE_READY async def sendMavStillCap( mySonyCam, stillcap, ConnID ): p = multiprocessing.current_process() print ('Starting Mavlink Still Capture :', p.name, p.pid) success = mySonyCam.sendMavlinkMessageForParamObject( stillcap, ConnID ) success = mySonyCam.sendMavlinkMessageForParamExtObject( stillcap, ConnID ) print ('Exiting Mavlink Still Capture :', multiprocessing.current_process().name) # # EXT param is just read directly from memory and sent back for speed # def mavlinkExtReqGetParam( mySonyCam, obj ): with obj.updateNeeded.get_lock(): obj.updateNeeded.value = True with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True def mavlinkReqGetParamStillCap( mySonyCam, obj ): if (mySonyCam.getSonyCamStillCapModeData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamWhiteBala( mySonyCam, obj ): if (mySonyCam.getSonyCamWhiteBalaData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamShutSpd( mySonyCam, obj ): if (mySonyCam.getSonyCamShutSpdData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamIso( mySonyCam, obj ): if (mySonyCam.getSonyCamISOData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamFocus( mySonyCam, obj ): if (mySonyCam.getSonyCamFocusData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamFocusArea( mySonyCam, obj ): if (mySonyCam.getSonyCamFocusAreaData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamAperture( mySonyCam, obj ): if (mySonyCam.getSonyApertureData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkReqGetParamExPro( mySonyCam, obj ): if (mySonyCam.getSonyCamExProData( obj )==True): with obj.timestamp.get_lock(): obj.timestamp.value = mySonyCam.my_timestamp() return True else: return False def mavlinkTakePhoto( mySonyCam, flg ): return (mySonyCam.take_a_picture_now(flg)) def get_cam_enum( nameS ): for s in sorted(camStateClass): if not s.name.find(nameS) == -1: return s.value return -1 def serviceParamRequestsOneAtATime( mySonyCam, mav2SonyVals, stcap, wb, ss, iso, pf, pfa, pa, expro ): p = multiprocessing.current_process() print ('Starting Service Mavlink incoming request packets ONE AT A TIME :', p.name, p.pid) if not (mav2SonyVals.mav_req_all_param.value == 0) and not (mavlinkSonyCamWriteVals.MAV_REQ_ALL_PARAM == mav2SonyVals.mav_ext_req_all_param.value): if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamStillCap)) == 0): stcap.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamStillCap( mySonyCam, stcap ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamStillCap if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamWhiteBala)) == 0): wb.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamWhiteBala( mySonyCam, wb ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamWhiteBala if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamShutSpd)) == 0): ss.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamShutSpd( mySonyCam, ss ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamShutSpd if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamIso)) == 0): iso.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamIso( mySonyCam, iso ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamIso if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamFocus)) == 0): pf.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamFocus( mySonyCam, pf ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamFocus if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamFocusArea)) == 0): pfa.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamFocusArea( mySonyCam, pfa ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamFocusArea if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamAperture)) == 0): pa.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamAperture( mySonyCam, pa ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamAperture if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamExPro)) == 0): expro.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if (mavlinkReqGetParamExPro( mySonyCam, expro ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamExPro if not (mav2SonyVals.mav_ext_req_all_param.value == 0) and not (mav2SonyVals.mav_ext_req_all_param.value == mavlinkSonyCamWriteVals.MAV_REQ_ALL_PARAM): if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamStillCap)) == 0): stcap.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamStillCap( mySonyCam, stcap ) == True ): if ( stcap.set_ack_send( True, stcap.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamStillCap if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamWhiteBala)) == 0): wb.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamWhiteBala( mySonyCam, wb ) == True ): if ( wb.set_ack_send( True, wb.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamWhiteBala if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamShutSpd)) == 0): ss.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamShutSpd( mySonyCam, ss ) == True ): if ( ss.set_ack_send( True, ss.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamShutSpd if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamIso)) == 0): iso.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamIso( mySonyCam, iso ) == True ): if ( iso.set_ack_send( True, iso.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamIso if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamFocus)) == 0): pf.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamFocus( mySonyCam, pf ) == True ): if ( pf.set_ack_send( True, pf.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamFocus if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamFocusArea)) == 0): pfa.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamFocusArea( mySonyCam, pfa ) == True ): if ( pfa.set_ack_send( True, pfa.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamFocusArea if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamAperture)) == 0): pa.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamAperture( mySonyCam, pa ) == True ): if ( pa.set_ack_send( True, pa.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamAperture if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamExPro)) == 0): expro.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if ( mavlinkReqGetParamExPro( mySonyCam, expro ) == True ): if ( expro.set_ack_send( True, expro.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamExPro print ('Exiting Service Mavlink incoming packet requests :', multiprocessing.current_process().name) # async def serviceParamRequests( mySonyCam, mav2SonyVals, stcap, wb, ss, iso, pf, pfa, pa, expro ): p = multiprocessing.current_process() print ('Starting Service Mavlink incoming request packets :', p.name, p.pid) if not (mav2SonyVals.mav_req_all_param.value == 0): if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamStillCap)) == 0): stcap.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamWhiteBala)) == 0): wb.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamShutSpd)) == 0): ss.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamIso)) == 0): iso.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamFocus)) == 0): pf.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamFocusArea)) == 0): pfa.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamAperture)) == 0): pa.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamExPro)) == 0): expro.set_update_flag( True, memoryValue.STATE_MAV_WRITING ) if not (mav2SonyVals.mav_ext_req_all_param.value == 0): if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamStillCap)) == 0): stcap.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamWhiteBala)) == 0): wb.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamShutSpd)) == 0): ss.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamIso)) == 0): iso.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamFocus)) == 0): pf.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamFocusArea)) == 0): pfa.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamAperture)) == 0): pa.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamExPro)) == 0): expro.set_ack_send( True, memoryValue.STATE_MAV_WRITING ) if not (mav2SonyVals.mav_req_all_param.value == 0): if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamStillCap)) == 0): if (mavlinkReqGetParamStillCap( mySonyCam, stcap ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamStillCap if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamWhiteBala)) == 0): if (mavlinkReqGetParamWhiteBala( mySonyCam, wb ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamWhiteBala if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamShutSpd)) == 0): if (mavlinkReqGetParamShutSpd( mySonyCam, ss ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamShutSpd if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamIso)) == 0): if (mavlinkReqGetParamIso( mySonyCam, iso ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamIso if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamFocus)) == 0): if (mavlinkReqGetParamFocus( mySonyCam, pf ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamFocus if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamFocusArea)) == 0): if (mavlinkReqGetParamFocusArea( mySonyCam, pfa ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamFocusArea if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamAperture)) == 0): if (mavlinkReqGetParamAperture( mySonyCam, pa ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamAperture if not ((int(mav2SonyVals.mav_req_all_param.value) & int(mav2SonyVals.ParamExPro)) == 0): if (mavlinkReqGetParamExPro( mySonyCam, expro ) == True): with mav2SonyVals.mav_req_all_param.get_lock(): mav2SonyVals.mav_req_all_param.value = mav2SonyVals.mav_req_all_param.value & ~mav2SonyVals.ParamExPro # QGC does not work like Mission Planner it may send this message many times # therefore request has been made to report back the obkect state rather than obtaining the data from the camera # if not (mav2SonyVals.mav_ext_req_all_param.value == 0): if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamStillCap)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, stcap ) == True ): if ( stcap.set_ack_send( True, stcap.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamStillCap if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamWhiteBala)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, wb ) == True ): if ( wb.set_ack_send( True, wb.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamWhiteBala if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamShutSpd)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, ss ) == True ): if ( ss.set_ack_send( True, ss.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamShutSpd if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamIso)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, iso ) == True ): if ( iso.set_ack_send( True, iso.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamIso if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamFocus)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, pf ) == True ): if ( pf.set_ack_send( True, pf.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamFocus if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamFocusArea)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, pfa ) == True ): if ( pfa.set_ack_send( True, pfa.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamFocusArea if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamAperture)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, pa ) == True ): if ( pa.set_ack_send( True, pa.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamAperture if not ((int(mav2SonyVals.mav_ext_req_all_param.value) & int(mav2SonyVals.ParamExPro)) == 0): if ( mavlinkExtReqGetParam( mySonyCam, expro ) == True ): if ( expro.set_ack_send( True, expro.STATE_CAM_READING ) == True ): # additional PARAM_EXT_VALUE message requested with mav2SonyVals.mav_ext_req_all_param.get_lock(): mav2SonyVals.mav_ext_req_all_param.value = mav2SonyVals.mav_ext_req_all_param.value & ~mav2SonyVals.ParamExPro print ('Exiting Service Mavlink incoming packet requests :', multiprocessing.current_process().name) # async def run_process_messages_from_connection_single(fra, the_connect, sharedObj): fra.process_messages_from_connection( the_connect, sharedObj ) # # @#= delete above after daemon fully tested # def run_process_messages_from_connection(fra, the_connect, sharedObj): while True: p = multiprocessing.current_process() print ('Starting: MavReader ', p.name, p.pid) fra.process_messages_from_connection( the_connect, sharedObj ) time.sleep(0.2) print ('Exiting MavReader :', multiprocessing.current_process().name) # ================ error handler if the camera fails (powers link on off) ============ # uses https://github.com/mvp/uhubctl # def reset_usb_camlink(): print("\033[31;43m executing reset usb camera link \033[0m") # p = os.popen('sudo /home/pi/cams/SonyTEST32/uhubctl/uhubctl -l 1-1 -a 0') print(p.read()) #cmd='sudo /home/pi/cams/SonyTEST32/uhubctl/uhubctl -l 1-1 -a 0' #args = shlex.split(cmd) #s=subprocess.run( args, stdout=subprocess.PIPE ) #output=s.stdout #print(output) time.sleep(2) p = os.popen('sudo /home/pi/cams/SonyTEST32/uhubctl/uhubctl -l 1-1 -a 1') print(p.read()) #cmd='sudo /home/pi/cams/SonyTEST32/uhubctl/uhubctl -l 1-1 -a 1' #args = shlex.split(cmd) #s=subprocess.run( args, stdout=subprocess.PIPE ) #output=s.stdout #print(output) # # had to add this to prevent a Killed occurring - no idea why? # time.sleep(50) print("\033[31m completed reset usb camera link \033[0m") def perform_usb_reset( mySonyCam ): if (mySonyCam.error_counts.value >= 5): reset_usb_camlink() with mySonyCamN.error_counts.get_lock(): mySonyCam.error_counts.value = 0 # # The heartbeat task # async def sendMavlinkHeartBeat_single(fm, cID, sleepTm=1): fm.mavlink_send_GCS_heartbeat(cID) while sleepTm > 0: time.sleep(1) print(f'{sleepTm} seconds') sleepTm -= 1 # # The ACK send thread # async def sendMavlinkAckData(fm, cID, sleep, cmd, rpm2, pro, res): fm.mavlink_send_ack_command(cID, cmd, rpm2, pro, res) while sleep > 0: #await asyncio.sleep(1) print(f'{sleep} seconds') sleep -= 1 # # The handle with ACK an error during collection that might happen during the send, its told to come again later or its wrong # async def execptionMavlinkErrorAckData(fm, cID): while fm.task_control_1 > 0: #await asyncio.sleep(1) if (fm.ACK_ERROR == fm.GOT_ERROR): fm.mavlink_send_ack_command(cID, fm.errRCV_COMMAND, fm.errRPM2, 0, mavutil.mavlink.MAV_RESULT_TEMPORARILY_REJECTED) fm.ACK_ERROR = 0 fm.errRCV_COMMAND = 0 fm.errRPM2 = 0 elif (fm.ACK_ERROR == fm.GOT_BAD): fm.mavlink_send_ack_command(cID, fm.errRCV_COMMAND, fm.errRPM2, 0, mavutil.mavlink.MAV_RESULT_FAILED) fm.ACK_ERROR = 0 # # The MSG send thread # async def processMavlinkMessageData(fm, cID, sleep, sonycam=0, caminst=0, redeyecam=0 ): # define what is sent in param1 myRedEyeCamera = 1 mySonyCamera = 2 mySonyCameraContShoot = 3 print(f"=================================== !!!!! in process !!!!!! ======================== {fm.type_of_msg}") if (fm.type_of_msg == 6500): # ## TODO :: Add the cmera retrieval class cam_data_result = fm.getCameraInfomationFromCam() # cam_data_result = fm.GOT_SUCCESS if (cam_data_result == fm.GOT_SUCCESS): fm.mavlink_send_camera_information(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS #exit(99) else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 6501): # ## TODO :: Add the cmera retrieval class cam_data_result = fm.getCameraSettingsFromCam() # cam_data_result = fm.GOT_SUCCESS if (cam_data_result == fm.GOT_SUCCESS): fm.mavlink_send_camera_settings(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 6502): # ## TODO :: Add the cmera retrieval class cam_data_result = fm.getStorageInfomationFromCam() # cam_data_result = fm.GOT_SUCCESS if (cam_data_result == fm.GOT_SUCCESS): fm.mavlink_send_storage_information(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS elif (fm.cam_data_result == fm.GOT_UNFORMAT): fm.mavlink_send_storage_information(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 6503): # ## TODO :: Add the cmera retrieval class cam_data_result = fm.getCameraCaptureStatusFromCam() # cam_data_result = fm.GOT_SUCCESS if (cam_data_result == fm.GOT_SUCCESS): fm.mavlink_send_camera_capture_status(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 6504): # ## TODO :: Add the cmera retrieval class cam_data_result = fm.getCameraCaptureInformationFromCam(self.Got_Param1) # cam_data_result = fm.GOT_SUCCESS if (cam_data_result == fm.GOT_SUCCESS): fm.mavlink_send_camera_capture_information(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 6505): # ## TODO :: Add the cmera retrieval class cam_data_result = fm.getVideoStreamInformationFromCam() # cam_data_result = fm.GOT_SUCCESS if (cam_data_result == fm.GOT_SUCCESS): fm.mavlink_send_video_stream_information(cID) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_SET_RELAY): # ## Sets the relay No passed from the mavlink command to the state requested # relay_data_result = fm.raspberry_pi3_set_relay(fm.Got_Param1,fm.Got_Param2) if (relay_data_result == True): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_VIDEO_STOP_CAPTURE): # # ## TODO :: add the camera control # # if (self.Got_Param1 == mySonyCamera): # cam_action_result = sonycam.stopMovieRec(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_VIDEO_START_CAPTURE): # # ## TODO :: add the camera control # # if (self.Got_Param1 == mySonyCamera): # cam_action_result = sonycam.startMovieRec(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_IMAGE_START_CAPTURE): # # ## TODO :: add the camera control # # if (self.Got_Param1 == myRedEyeCamera): # cam_action_result = redeyecam.redEyeCapture() # if (cam_action_result == redeyecam.HTTP_SUCCESS_RETURN): # cam_action_result = fm.GOT_SUCCESS # elif (self.Got_Param1 == mySonyCamera): # cam_action_result = sonycam.saveOnePicture(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # elif (self.Got_Param1 == mySonyCameraContShoot): # cam_action_result = sonycam.startContShooting(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_IMAGE_STOP_CAPTURE): # # ## TODO :: add the camera control # # if (self.Got_Param1 == mySonyCameraContShoot): # cam_action_result = sonycam.stopContShooting(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_VIDEO_STOP_STREAMING): # # ## TODO :: add the camera control # # if (self.Got_Param1 == mySonyCam): # cam_action_result = sonycam.stopLiveView(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_VIDEO_START_STREAMING): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # if (self.Got_Param1 == mySonyCam): # cam_action_result = sonycam.startLiveView(caminst) # if not cam_action_result.find("OK") == -1: # cam_action_result = fm.GOT_SUCCESS # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_SET_CAMERA_MODE): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavdefs.MAV_CMD_SET_CAMERA_ZOOM): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavdefs.MAV_CMD_SET_CAMERA_FOCUS): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONFIGURE): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_DIGICAM_CONTROL): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_CONTROL_VIDEO): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_RESET_CAMERA_SETTINGS): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_MOUNT_CONTROL_QUAT): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED #elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # # cam_action_result = fm.GOT_SUCCESS # if (cam_action_result == fm.GOT_SUCCESS): # fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS # else: # fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_TRIGGER_CONTROL): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 2004): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 2005): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == 2010): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_STORAGE_FORMAT): # ## Sets the relay No passed from the mavlink command to the state requested # ## TODO :: add the camera control # # cam_action_result = fm.GOT_SUCCESS if (cam_action_result == fm.GOT_SUCCESS): fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_FAILED elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_REQUEST_CAMERA_INFORMATION): print("============================= CAMERA INFO MESSAGE ================================== ") fm.mavlink_send_camera_information(cID) elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_REQUEST_VIDEO_STREAM_INFORMATION): print("requested video stream information") fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS elif (fm.type_of_msg == mavutil.mavlink.MAV_CMD_DO_SET_SERVO): print("setting the relay output %d %d"%(fm.Got_Param1,fm.Got_Param2)) fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS else: print(f"unknown message {fm.type_of_msg}") fm.ACK_RESULT = mavutil.mavlink.MAV_RESULT_IN_PROGRESS while sleep > 0: #await asyncio.sleep(1) print(f'{sleep} seconds') sleep -= 1 fm.task_control_1 = 0 # # @#= delete above after daemon tested # def sendMavlinkHeartBeat(fm, cID, sleepTm=1): while True: fm.mavlink_send_GCS_heartbeat(cID) time.sleep(sleepTm) print(f"\033[36;44m HeartBEAT !!!!! ============= {sleepTm} seconds ================= \033[0m") # sleepTm -= 1 #def sendMavlinkAckData(fm, cID, sleep, cmd, rpm2, pro, res): # ret = fm.mavlink_send_ack_command(cID, cmd, rpm2, pro, res) # while sleep > 0: # #await asyncio.sleep(1) # print(f'{sleep} seconds') # sleep -= 1 # return ret # ================ mpi writer and reader functions ============== # from mpi4py import MPI import numpy as np def sendTagOverMPILink( tag_name ): # # convert string to ascii list and make numpy array from it. # vn = [] k = 0 for k in range(len(tag_name)): vn.append(ord(tag_name[k])) u8_tag_name = np.array(vn, np.uint8) data = np.array(u8_tag_name, dtype="float64") comm.Send(data, dest=1, tag=0) print('\033[33m MPI Process {} sent string data: \033[9m'.format(rank), data) def sendValueListOverMPILink( tagValues ): loop - 0 for loop in range(0,len(tagValues)): tagValue = tagValues[loop] list1 = [] list1.append(tagValue) data = np.array(list1, dtype="float64") comm.Send(data, dest=1, tag=0) print('\033[35m MPI Process {} sent data values list: \033[0m'.format(rank), data) def readTagOverMPILink(): # initialize the receiving buffer to 20 elements max char size for tag # data = np.zeros(20) # receive data from master process (first its the tag as a string) # comm.Recv(data, source=0, tag=0) # convert the object recieved back to a list and then convert it to a string # list1 = data.tolist() tagName = "" for s in range(0,len(list1)): tagName = tagName + chr(int(list1[s])) print(f"\033[32m MPI Process {rank} received the tagname \033[31;46m {tagName} \033[0m") return tagName def readValueListOverMPILink(): # initialize the receiving buffer to 20 elements max char size for tag # data = np.zeros(20) # receive data from master process (second its the values associated as floating point numbers) # comm.Recv(data, source=0, tag=0) # convert it back to a list and parse its values to the variables # list1 = [] list1 = data.tolist() if (len(list1) >= 2): print('Process {} received data index number :'.format(rank), int(list1[1])) print('Process {} received data value :'.format(rank), list1[0]) return list1 # # ================ signal handlers ============================== # # # from a signal.alarm # def raised_signal_handler(a,b): print("\033[32m ============ Take Picture ==================") fastGlobals.take_picture = 1 # do the action here # # CTL-C # def ctlc_handler(signum, frame): print("Signal Number:", signum, " Frame: ", frame) # # CTL-Z # def exit_handler(signum, frame): print('Exiting....') exit(0) # # on getting kill -SIGUSR1 # def sigusr1_handler(signum, frame): print("signal hander with a kill -SIGUSR1 (signal.SIGUSR1)") # what we want to do on that external signal print("\033[32m ============ Take Picture ==================") fastGlobals.take_picture = 1 # # The main thread to run this is the camera receiver client # async def main(): # ========================== SIGNAL HANDLERS ================================================= # Register the alarm signal with our handler signal. signal(signal. SIGALRM, alarm_handler) signal.signal(signal.SIGALRM, raised_signal_handler) # to raise this insert this anywhere in code # signal.alarm(1) # Register our signal handler with `SIGINT`(CTRL + C) signal.signal(signal.SIGINT, ctlc_handler) # Register the exit handler with `SIGTSTP` (Ctrl + Z) signal.signal(signal.SIGTSTP, exit_handler) # external signal handler signal.signal(signal.SIGUSR1, sigusr1_handler) # ========================== MULTI_TASKING ==================================================== # create the sequential state variable for the scheduler working on # the camera operations that must be in series # and the choice of operation (camera feature) that will execute at each state # mp_heart = multiprocessing.Value('i', 0) # initialise pool data - this is the maximum number of operations for the paralel operations group # max_number_processes = 8 # ========================= MAVLINK ============================================================= frame = MAVFrame() state = False while (state == False): try: cID,state = frame.makeMAVlinkConn() except Exception as e: print("Error Trap :: ", e.__class__, " occurred.") print("\033[31m connected to mavlink \033[0m") # wait heartbeat # if it sends another sys id we need to change it # state = False xx = 1 while xx == 1: print(f"\033[31m receive ? {xx} \033[0m") try: m = cID.recv_match(type="HEARTBEAT", blocking=True, timeout=10) except Exception as e: print("Error Trap :: ", e.__class__, " occurred.") if not (m == None): if not ( m.autopilot == mavutil.mavlink.MAV_AUTOPILOT_INVALID ): xx = 2 print(f"\033[33m receive ? {xx} \033[0m") print(f"\033[32m receive complete ? {xx} \033[0m") id = m.get_srcSystem() print("\033[31m heartbeat \033[0m") if not ( m.get_srcSystem() == frame.DEFAULT_SYS_ID ) : print(f"-------- new id found -------- {id}") while (state == False): try: cID,state = frame.makeNewMAVlinkConn(id) except Exception as e: print("Error Trap :: ", e.__class__, " occurred.") print("\033[31m to logger \033[0m") # default logger # # multiprocessing.log_to_stderr(logging.DEBUG) # # for extra logging use this # instead # multiprocessing.log_to_stderr() #logger = multiprocessing.get_logger() #logger.setLevel(logging.INFO) # # create instance of sony alpha cam (new API) # mySonyCamNo1 = sonyAlphaNewCamera() # # create an instance of common write structure # from mavlink reader task to the camera # gcsWrites2Sony = mavlinkSonyCamWriteVals() print("\033[31m getting data \033[0m") # # init the objects with camera data # & set rhw data to be written back to gcs via mavlink # # # Initialise all shared object data between # camera and mavlink processes # expro = mySonyCamNo1.initSonyCamExProData( ) aper = mySonyCamNo1.initSonyApertureData( ) focusdata = mySonyCamNo1.initSonyCamFocusData( ) focusarea = mySonyCamNo1.initSonyCamFocusAreaData( ) iso = mySonyCamNo1.initSonyCamISOData( ) shut_sp = mySonyCamNo1.initSonyCamShutSpdData( ) whitebal = mySonyCamNo1.initSonyCamWhiteBalaData( ) stillcap = mySonyCamNo1.initSonyCamStillCapModeData( ) print("\033[31m got data \033[0m") # this is a rough trap for now but if its all zeros its not getting correct data from the camera then try reset the link first # no need to aquire as this is working in single task mode at this point if ((((((((expro.signal.value == 0) and (aper.signal.value == 0)) and (focusdata.signal.value == 0)) and (focusarea.signal.value == 0)) and (iso.signal.value == 0)) and (shut_sp.signal.value == 0)) and (whitebal.signal.value == 0)) and (stillcap.signal.value == 0)): reset_usb_camlink() retCode = mySonyCamNo1.getSonyCamExProData( expro ) retCode = mySonyCamNo1.getSonyApertureData( aper ) retCode = mySonyCamNo1.getSonyCamFocusData( focusdata ) retCode = mySonyCamNo1.getSonyCamFocusAreaData( focusarea ) retCode = mySonyCamNo1.getSonyCamISOData( iso ) retCode = mySonyCamNo1.getSonyCamShutSpdData( shut_sp ) retCode = mySonyCamNo1.getSonyCamWhiteBalaData( whitebal ) retCode = mySonyCamNo1.getSonyCamStillCapModeData( stillcap ) # uncomment these if you dont want immediate update message # #expro.timestamp = mySonyCamNo1.my_timestamp() #aper.timestamp = mySonyCamNo1.my_timestamp() #focusdata.timestamp = mySonyCamNo1.my_timestamp() #focusarea.timestamp = mySonyCamNo1.my_timestamp() #iso.timestamp = mySonyCamNo1.my_timestamp() #shut_sp.timestamp = mySonyCamNo1.my_timestamp() #whitebal.timestamp = mySonyCamNo1.my_timestamp() #stillcap.timestamp = mySonyCamNo1.my_timestamp() # ========== send back to GCS via mavlink if a new change of state has been detected or polled if requested # doMavIsoTask = asyncio.create_task(sendMavIso(mySonyCamNo1, iso, cID )) doMavAperTask = asyncio.create_task(sendMavAper( mySonyCamNo1, aper, cID )) doMavFocusTask = asyncio.create_task(sendMavFocusData( mySonyCamNo1, focusdata, focusarea, cID )) doMavExproTask = asyncio.create_task(sendMavExpro( mySonyCamNo1, expro, cID )) doMavShutSpdTask = asyncio.create_task(sendMavShutSpd( mySonyCamNo1, shut_sp, cID )) doMavWhiteBalTask = asyncio.create_task(sendMavWhiteBala( mySonyCamNo1, whitebal, cID )) doMavStillCapTask = asyncio.create_task(sendMavStillCap( mySonyCamNo1, stillcap, cID )) await doMavIsoTask await doMavAperTask await doMavFocusTask await doMavExproTask await doMavShutSpdTask await doMavWhiteBalTask await doMavStillCapTask # # now set the class to be initialised # gcsWrites2Sony.init_class_state() # # test iso write (single task mode) # # ### If you want this in single task mode ### # active = True # # ### If you want this in multi mode ### # # active = False # initialise the scheduler the list is rotational each time we re-schedule # #schedule = list(range(1,8)) while active==True: recieveTask = asyncio.create_task(run_process_messages_from_connection_single(frame, cID, gcsWrites2Sony)) if (mp_heart.value == 0): heartTask = asyncio.create_task(sendMavlinkHeartBeat_single(frame, cID, 0)) paramReqTask = asyncio.create_task(serviceParamRequests( mySonyCamNo1, gcsWrites2Sony, stillcap, whitebal, shut_sp, iso, focusdata, focusarea, aper, expro )) if (gcsWrites2Sony.mp_state.value == mavlinkSonyCamWriteVals.FUNC_IDLE): # change schedule first = last # #schedule.append(schedule[0]) #schedule.pop(0) if not (gcsWrites2Sony.set_sony_iso.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_iso.value == gcsWrites2Sony.prev_sony_iso.value): print(f"on TOP LEVEL saw {gcsWrites2Sony.set_sony_iso.value} {gcsWrites2Sony.prev_sony_iso.value} {gcsWrites2Sony.mav_req_all_param.value}") doIsoTask = asyncio.create_task(doAlphaCameraIso(mySonyCamNo1, gcsWrites2Sony, iso)) if not (gcsWrites2Sony.set_sony_aperture.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_aperture.value == gcsWrites2Sony.prev_sony_aperture.value): print(f"on TOP LEVEL saw aperture {gcsWrites2Sony.set_sony_aperture.value} {gcsWrites2Sony.prev_sony_aperture.value} {gcsWrites2Sony.mav_req_all_param.value}") doAperTask = asyncio.create_task(doAlphaCameraAperture(mySonyCamNo1, gcsWrites2Sony, aper)) if not (gcsWrites2Sony.set_sony_white_bal.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_white_bal.value == gcsWrites2Sony.prev_sony_white_bal.value): print(f"on TOP LEVEL saw wb {gcsWrites2Sony.set_sony_white_bal.value} {gcsWrites2Sony.prev_sony_white_bal.value} {gcsWrites2Sony.mav_req_all_param.value}") doWhiBalTask = asyncio.create_task(doAlphaWhiteBala(mySonyCamNo1, gcsWrites2Sony, whitebal)) if not (gcsWrites2Sony.set_sony_ex_pro.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_ex_pro.value == gcsWrites2Sony.prev_sony_ex_pro.value): print(f"on TOP LEVEL saw expro {gcsWrites2Sony.set_sony_ex_pro.value} {gcsWrites2Sony.prev_sony_ex_pro.value} {gcsWrites2Sony.mav_req_all_param.value}") doExProTask = asyncio.create_task(doAlphaCameraExpro(mySonyCamNo1, gcsWrites2Sony, expro)) if not (gcsWrites2Sony.set_sony_still_cap_mode.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_still_cap.value == gcsWrites2Sony.prev_sony_still_cap_mode.value): print(f"on TOP LEVEL saw still cap {gcsWrites2Sony.set_sony_still_cap_mode.value} {gcsWrites2Sony.prev_sony_still_cap_mode.value} {gcsWrites2Sony.mav_req_all_param.value}") doStillCapTask = asyncio.create_task(doAlphaCameraStillCap(mySonyCamNo1, gcsWrites2Sony, stillcap)) if not (gcsWrites2Sony.set_sony_shutter.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_shutter.value == gcsWrites2Sony.prev_sony_shutter.value): print(f"on TOP LEVEL saw shutter speed {gcsWrites2Sony.set_sony_shutter.value} {gcsWrites2Sony.prev_sony_shutter.value} {gcsWrites2Sony.mav_req_all_param.value}") doShutSpdTask = asyncio.create_task(doAlphaCameraShutSpd(mySonyCamNo1, gcsWrites2Sony, shut_sp)) if not (gcsWrites2Sony.set_sony_focus.value == gcsWrites2Sony.STATE_INIT) or not (gcsWrites2Sony.set_sony_focus_area.value == gcsWrites2Sony.STATE_INIT) and not (gcsWrites2Sony.set_sony_focus.value == gcsWrites2Sony.prev_sony_focus.value) and not (gcsWrites2Sony.set_sony_focus_area.value == gcsWrites2Sony.prev_sony_focus_area.value): print(f"on TOP LEVEL saw shutter speed {gcsWrites2Sony.set_sony_focus.value} {gcsWrites2Sony.prev_sony_focus.value} {gcsWrites2Sony.set_sony_focus_area.value} {gcsWrites2Sony.prev_sony_focus_area.value} {gcsWrites2Sony.mav_req_all_param.value}") doFocusTask = asyncio.create_task(doAlphaCameraFocusData(mySonyCamNo1, gcsWrites2Sony, focusdata, focusarea)) if (frame.ACK_RESULT == mavutil.mavlink.MAV_RESULT_ACCEPTED): snd_task_2 = asyncio.create_task(sendMavlinkAckData(frame, cID, 1, frame.RCV_COMMAND, frame.RPM2, 0, frame.ACK_RESULT )) await snd_task_2 print("ack end....................................................................") frame.task_control_1 = 1 #snd_task_3 = asyncio.create_task(processMavlinkMessageData(frame, cID, 1, pysonyCam, camInst, redEyeCam)) snd_task_3 = asyncio.create_task(processMavlinkMessageData(frame, cID, 2)) exc_task_error_handler = asyncio.create_task(execptionMavlinkErrorAckData(frame, cID)) await snd_task_3 await exc_task_error_handler print(f"end 2 tasks...............................{frame.RCV_COMMAND} {frame.RPM2} {frame.ACK_RESULT}") snd_task_2 = asyncio.create_task(sendMavlinkAckData(frame, cID, 1, frame.RCV_COMMAND, frame.RPM2, 100, frame.ACK_RESULT )) await snd_task_2 # re-enable when you want to check this again exit(55) print("ack end2...................................................................") frame.RCV_COMMAND = 0 frame.ACK_RESULT = frame.ACK_ALL_DATA_COMPLETE doMavIsoTask = asyncio.create_task(sendMavIso(mySonyCamNo1, iso, cID )) doMavAperTask = asyncio.create_task(sendMavAper( mySonyCamNo1, aper, cID )) doMavFocusTask = asyncio.create_task(sendMavFocusData( mySonyCamNo1, focusdata, focusarea, cID )) doMavExproTask = asyncio.create_task(sendMavExpro( mySonyCamNo1, expro, cID )) doMavShutSpdTask = asyncio.create_task(sendMavShutSpd( mySonyCamNo1, shut_sp, cID )) doMavWhiteBalTask = asyncio.create_task(sendMavWhiteBala( mySonyCamNo1, whitebal, cID )) doMavStillCapTask = asyncio.create_task(sendMavStillCap( mySonyCamNo1, stillcap, cID )) await doMavIsoTask await doMavAperTask await doMavFocusTask await doMavExproTask await doMavShutSpdTask await doMavWhiteBalTask await doMavStillCapTask #if (mySonyCamNo1.error_counts.value >= 5): # reset_usb_camlink() # with mySonyCamNo1.error_counts.get_lock(): # mySonyCamNo1.error_counts.value = 0 print("completed..................................................") recieveTask.cancel() print(f"Ended: {time.strftime('%X')}") with mp_heart.get_lock(): mp_heart.value += 1 mp_heart.value = mp_heart.value % 12 await paramReqTask # # Release the shared memory # del expro del stillcap del aper del focusdata del focusarea del shut_sp del whitebal del stillcap if __name__ == '__main__': asyncio.run(main())
46.62276
348
0.539467
39,909
364,217
4.74725
0.047408
0.01736
0.011844
0.012414
0.782569
0.751227
0.731049
0.709783
0.684331
0.664401
0
0.028523
0.368064
364,217
7,812
349
46.62276
0.794623
0.169893
0
0.647351
0
0.022683
0.090268
0.012058
0
0
0
0.000128
0
1
0.044834
false
0.001063
0.00443
0.000709
0.138579
0.089137
0
0
0
null
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
43bcba6c99534eb04ca88a1e3caaaa22871c7c05
69
py
Python
data/floor_dataset.py
chnghia/pytorch-lightning-gan
3e484ea8eca2a3365a6b209a979a95a5b2e4a6f2
[ "MIT" ]
3
2020-10-07T01:24:43.000Z
2021-04-13T15:03:19.000Z
data/floor_dataset.py
chnghia/pytorch-lightning-gan
3e484ea8eca2a3365a6b209a979a95a5b2e4a6f2
[ "MIT" ]
null
null
null
data/floor_dataset.py
chnghia/pytorch-lightning-gan
3e484ea8eca2a3365a6b209a979a95a5b2e4a6f2
[ "MIT" ]
null
null
null
import os from torch.utils.data import Dataset from PIL import Image
17.25
36
0.826087
12
69
4.75
0.75
0
0
0
0
0
0
0
0
0
0
0
0.144928
69
3
37
23
0.966102
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
43d4ed83cf6e78d88a9f8ab02d4dff31840228a0
5,627
py
Python
custom/icds_reports/migrations/0065_ccsrecordmonthlyview.py
kkrampa/commcare-hq
d64d7cad98b240325ad669ccc7effb07721b4d44
[ "BSD-3-Clause" ]
1
2020-05-05T13:10:01.000Z
2020-05-05T13:10:01.000Z
custom/icds_reports/migrations/0065_ccsrecordmonthlyview.py
kkrampa/commcare-hq
d64d7cad98b240325ad669ccc7effb07721b4d44
[ "BSD-3-Clause" ]
1
2019-12-09T14:00:14.000Z
2019-12-09T14:00:14.000Z
custom/icds_reports/migrations/0065_ccsrecordmonthlyview.py
MaciejChoromanski/commcare-hq
fd7f65362d56d73b75a2c20d2afeabbc70876867
[ "BSD-3-Clause" ]
5
2015-11-30T13:12:45.000Z
2019-07-01T19:27:07.000Z
# -*- coding: utf-8 -*- # Generated by Django 1.10.7 on 2018-09-12 13:40 from __future__ import absolute_import, unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('icds_reports', '0064_aggregateccsrecordmontly_home_visit_date'), ] operations = [ migrations.CreateModel( name='CcsRecordMonthlyView', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('awc_id', models.TextField(primary_key=True)), ('awc_name', models.TextField(blank=True, null=True)), ('awc_site_code', models.TextField(blank=True, null=True)), ('supervisor_id', models.TextField(blank=True, null=True)), ('supervisor_name', models.TextField(blank=True, null=True)), ('supervisor_site_code', models.TextField(blank=True, null=True)), ('block_id', models.TextField(blank=True, null=True)), ('block_name', models.TextField(blank=True, null=True)), ('block_site_code', models.TextField(blank=True, null=True)), ('district_id', models.TextField(blank=True, null=True)), ('district_name', models.TextField(blank=True, null=True)), ('district_site_code', models.TextField(blank=True, null=True)), ('state_id', models.TextField(blank=True, null=True)), ('state_name', models.TextField(blank=True, null=True)), ('state_site_code', models.TextField(blank=True, null=True)), ('block_map_location_name', models.TextField(blank=True, null=True)), ('district_map_location_name', models.TextField(blank=True, null=True)), ('state_map_location_name', models.TextField(blank=True, null=True)), ('month', models.DateField(blank=True, null=True)), ('add', models.DateField(blank=True, null=True)), ('age_in_months', models.IntegerField(blank=True, null=True)), ('anc_hemoglobin', models.DecimalField(max_digits=64, decimal_places=20, blank=True, null=True)), ('anc_weight', models.SmallIntegerField(blank=True, null=True)), ('anemic_moderate', models.IntegerField(blank=True, null=True)), ('anemic_normal', models.IntegerField(blank=True, null=True)), ('anemic_severe', models.IntegerField(blank=True, null=True)), ('anemic_unknown', models.IntegerField(blank=True, null=True)), ('bleeding', models.SmallIntegerField(blank=True, null=True)), ('blurred_vision', models.SmallIntegerField(blank=True, null=True)), ('bp_dia', models.SmallIntegerField(blank=True, null=True)), ('bp_sys', models.SmallIntegerField(blank=True, null=True)), ('breastfed_at_birth', models.SmallIntegerField(blank=True, null=True)), ('case_id', models.TextField(primary_key=True)), ('convulsions', models.SmallIntegerField(blank=True, null=True)), ('counsel_accessible_postpartum_fp', models.IntegerField(blank=True, null=True)), ('counsel_bp_vid', models.IntegerField(blank=True, null=True)), ('counsel_fp_methods', models.IntegerField(blank=True, null=True)), ('counsel_fp_vid', models.IntegerField(blank=True, null=True)), ('counsel_immediate_bf', models.IntegerField(blank=True, null=True)), ('counsel_immediate_conception', models.IntegerField(blank=True, null=True)), ('counsel_preparation', models.IntegerField(blank=True, null=True)), ('delivery_nature', models.SmallIntegerField(blank=True, null=True)), ('edd', models.DateField(blank=True, null=True)), ('home_visit_date', models.DateField(blank=True, null=True)), ('ifa_consumed_last_seven_days', models.IntegerField(blank=True, null=True)), ('institutional_delivery_in_month', models.IntegerField(blank=True, null=True)), ('is_ebf', models.SmallIntegerField(blank=True, null=True)), ('last_date_thr', models.DateField(blank=True, null=True)), ('mobile_number', models.TextField(blank=True, null=True)), ('num_anc_complete', models.SmallIntegerField(blank=True, null=True)), ('num_pnc_visits', models.SmallIntegerField(blank=True, null=True)), ('num_rations_distributed', models.IntegerField(blank=True, null=True)), ('opened_on', models.DateField(blank=True, null=True)), ('person_name', models.TextField(blank=True, null=True)), ('preg_order', models.SmallIntegerField(blank=True, null=True)), ('pregnant', models.IntegerField(blank=True, null=True)), ('rupture', models.SmallIntegerField(blank=True, null=True)), ('swelling', models.SmallIntegerField(blank=True, null=True)), ('trimester', models.IntegerField(blank=True, null=True)), ('tt_1', models.DateField(blank=True, null=True)), ('tt_2', models.DateField(blank=True, null=True)), ('using_ifa', models.IntegerField(blank=True, null=True)), ], options={ 'db_table': 'ccs_record_monthly_view', 'managed': False, }, ) ]
63.943182
114
0.608139
590
5,627
5.622034
0.242373
0.162798
0.235152
0.307507
0.746458
0.733494
0.412421
0.194453
0.069641
0
0
0.00636
0.245602
5,627
87
115
64.678161
0.775029
0.012085
0
0
1
0
0.170086
0.050756
0
0
0
0
0
1
0
false
0
0.025
0
0.0625
0
0
0
0
null
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
43dd875b1b50147892c1197c075bd8bbd61f046e
136
py
Python
supernodes/apps.py
ockibagusp/cloud-platform
a9fd369c51d8e2aa1b2fd51d11f2cb16b018bf66
[ "MIT" ]
1
2019-09-29T06:24:19.000Z
2019-09-29T06:24:19.000Z
supernodes/apps.py
ockibagusp/cloud-platform
a9fd369c51d8e2aa1b2fd51d11f2cb16b018bf66
[ "MIT" ]
1
2020-11-23T10:03:46.000Z
2020-11-23T10:03:46.000Z
supernodes/apps.py
OckiFals/cloud-platform
c62eba7fcc08b06485b845089e79b3ce236ec1ec
[ "MIT" ]
null
null
null
from __future__ import unicode_literals from django.apps import AppConfig class SupernodesConfig(AppConfig): name = 'supernodes'
17
39
0.801471
15
136
6.933333
0.8
0
0
0
0
0
0
0
0
0
0
0
0.147059
136
7
40
19.428571
0.896552
0
0
0
0
0
0.073529
0
0
0
0
0
0
1
0
false
0
0.5
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
43e2972a21a612cd9d1f29dcb18be607e9a4f0b1
1,023
py
Python
optimus/agg.py
atwoodjw/Optimus
938463cec41a6683d2077c9afc7d6ba05c3b993f
[ "Apache-2.0" ]
1
2020-08-15T06:58:59.000Z
2020-08-15T06:58:59.000Z
optimus/agg.py
atwoodjw/Optimus
938463cec41a6683d2077c9afc7d6ba05c3b993f
[ "Apache-2.0" ]
null
null
null
optimus/agg.py
atwoodjw/Optimus
938463cec41a6683d2077c9afc7d6ba05c3b993f
[ "Apache-2.0" ]
null
null
null
from pypika import analytics as an from pyspark.sql import functions as F ENGINE = "spark" agg_mapping = { "min": {"spark": F.min, "sql": an.Min}, "max": {"spark": F.max, "sql": an.Max} } funcs = [F.min, F.max, F.stddev, F.kurtosis, F.mean, F.skewness, F.sum, F.variance] class Agg: @staticmethod def min(): return agg_mapping["min"][ENGINE] @staticmethod def max(): return agg_mapping["max"][ENGINE] @staticmethod def stddev(): return agg_mapping["stddev"][ENGINE] @staticmethod def kurtosis(): # https://www.periscopedata.com/blog/understanding-outliers-with-skew-and-kurtosis return agg_mapping["stddev"][ENGINE] @staticmethod def mean(): return agg_mapping["mean"][ENGINE] @staticmethod def skewness(): return agg_mapping["mean"][ENGINE] @staticmethod def sum(): return agg_mapping["mean"][ENGINE] @staticmethod def variance(): return agg_mapping["mean"][ENGINE]
21.765957
90
0.621701
125
1,023
5.016
0.296
0.143541
0.204147
0.127592
0.374801
0.333333
0.333333
0
0
0
0
0
0.233627
1,023
46
91
22.23913
0.799745
0.078201
0
0.424242
0
0
0.064825
0
0
0
0
0
0
1
0.242424
false
0
0.060606
0.242424
0.575758
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
1
0
0
4
78e3a5a58bf95c4c039d3057796f33ce55d5a06d
83
py
Python
pytest_intercept_remote/__init__.py
devanshshukla99/pytest-intercept
e0b79c874206864d7cda3d487e263495138ca7bd
[ "BSD-3-Clause" ]
1
2022-01-24T03:52:55.000Z
2022-01-24T03:52:55.000Z
pytest_intercept_remote/__init__.py
devanshshukla99/pytest-intercept
e0b79c874206864d7cda3d487e263495138ca7bd
[ "BSD-3-Clause" ]
3
2021-05-23T00:05:02.000Z
2021-06-24T10:24:52.000Z
pytest_intercept_remote/__init__.py
devanshshukla99/pytest-intercept
e0b79c874206864d7cda3d487e263495138ca7bd
[ "BSD-3-Clause" ]
null
null
null
# flake8: noqa from pytest_intercept_remote._version import version as __version__
27.666667
67
0.855422
11
83
5.818182
0.818182
0
0
0
0
0
0
0
0
0
0
0.013514
0.108434
83
2
68
41.5
0.851351
0.144578
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
6031dd58c8011407ba81972f9359c932851b6201
187
py
Python
config/wsgi.py
BlickLabs/mailchimp
fc1f781be43c8f8cad9898f06be6bf947da0ef9c
[ "BSD-3-Clause" ]
null
null
null
config/wsgi.py
BlickLabs/mailchimp
fc1f781be43c8f8cad9898f06be6bf947da0ef9c
[ "BSD-3-Clause" ]
null
null
null
config/wsgi.py
BlickLabs/mailchimp
fc1f781be43c8f8cad9898f06be6bf947da0ef9c
[ "BSD-3-Clause" ]
null
null
null
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.core.wsgi import get_wsgi_application import os application = get_wsgi_application()
17
49
0.770053
26
187
5.192308
0.692308
0.103704
0.266667
0
0
0
0
0
0
0
0
0.006135
0.128342
187
10
50
18.7
0.822086
0.224599
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.75
0
0.75
0
1
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
60324954ef522e37fbaf481aa453f830dda91a2c
83
py
Python
tools/mo/openvino/tools/mo/utils/ir_reader/__init__.py
pazamelin/openvino
b7e8ef910d7ed8e52326d14dc6fd53b71d16ed48
[ "Apache-2.0" ]
2,406
2020-04-22T15:47:54.000Z
2022-03-31T10:27:37.000Z
tools/cross_check_tool/openvino/tools/cross_check_tool/__init__.py
thomas-yanxin/openvino
031e998a15ec738c64cc2379d7f30fb73087c272
[ "Apache-2.0" ]
4,948
2020-04-22T15:12:39.000Z
2022-03-31T18:45:42.000Z
tools/cross_check_tool/openvino/tools/cross_check_tool/__init__.py
thomas-yanxin/openvino
031e998a15ec738c64cc2379d7f30fb73087c272
[ "Apache-2.0" ]
991
2020-04-23T18:21:09.000Z
2022-03-31T18:40:57.000Z
# Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0
20.75
43
0.759036
12
83
5.25
1
0
0
0
0
0
0
0
0
0
0
0.136986
0.120482
83
3
44
27.666667
0.726027
0.927711
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
6041eacefb28b5a1dd3bf5b9b0d3bcd9c24fabb2
350
py
Python
model/project.py
arseny-tsyro/python_training_mantis
2b20d88fe03d8b25cd31b0b97f7e9cf5a612a702
[ "Apache-2.0" ]
null
null
null
model/project.py
arseny-tsyro/python_training_mantis
2b20d88fe03d8b25cd31b0b97f7e9cf5a612a702
[ "Apache-2.0" ]
null
null
null
model/project.py
arseny-tsyro/python_training_mantis
2b20d88fe03d8b25cd31b0b97f7e9cf5a612a702
[ "Apache-2.0" ]
null
null
null
__author__ = 'Arseniy' class Project: def __init__(self, name="", description=""): self.name = name self.description = description def __repr__(self): return "%s; %s" % (self.name, self.description) def __eq__(self, other): return self.name == other.name def name(self): return self.name
19.444444
55
0.597143
40
350
4.825
0.35
0.207254
0.196891
0
0
0
0
0
0
0
0
0
0.274286
350
17
56
20.588235
0.759843
0
0
0
0
0
0.037143
0
0
0
0
0
0
1
0.363636
false
0
0
0.272727
0.727273
0
0
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
4
6044f579e76af8556910cff5fb9defac2a03e0f1
616
py
Python
credentials.py
paulmunyao/Password-Locker
918aa30ecadc1ea09cd09b2945e57e0f3ac67b7e
[ "Unlicense" ]
null
null
null
credentials.py
paulmunyao/Password-Locker
918aa30ecadc1ea09cd09b2945e57e0f3ac67b7e
[ "Unlicense" ]
null
null
null
credentials.py
paulmunyao/Password-Locker
918aa30ecadc1ea09cd09b2945e57e0f3ac67b7e
[ "Unlicense" ]
null
null
null
class credentials: ''' Class that generates new instances of credentials ''' credentials_list = [] def __init__(self, user_name, password): self.user_name = user_name self.password = password ''' __init__method that helps define properties for our objects. Args: user_name: user name passord : password of the user ''' def save_credentials(self): ''' save_credentials method saves the user object into the database/user_list ''' credentials.user_list.append(self)
25.666667
81
0.589286
65
616
5.323077
0.461538
0.115607
0.069364
0.092486
0
0
0
0
0
0
0
0
0.340909
616
24
82
25.666667
0.852217
0.199675
0
0
1
0
0
0
0
0
0
0
0
1
0.285714
false
0.285714
0
0
0.571429
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
1
0
1
0
0
1
0
0
4
6053cbdf70ac106600c35b655f449c2f8e181ea2
32
py
Python
2017/9_Sep/21/01-test.py
z727354123/pyCharmTest
9cbd770e19929cb4feb3be2f13b60dc0b1f68b56
[ "Apache-2.0" ]
null
null
null
2017/9_Sep/21/01-test.py
z727354123/pyCharmTest
9cbd770e19929cb4feb3be2f13b60dc0b1f68b56
[ "Apache-2.0" ]
null
null
null
2017/9_Sep/21/01-test.py
z727354123/pyCharmTest
9cbd770e19929cb4feb3be2f13b60dc0b1f68b56
[ "Apache-2.0" ]
null
null
null
text = type(type) print(text)
6.4
17
0.65625
5
32
4.2
0.6
0
0
0
0
0
0
0
0
0
0
0
0.1875
32
4
18
8
0.807692
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.5
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
6085ca3b666758b345704a3a793124e55aacd7b7
641
py
Python
app.py
jrichardson12/portfolio
aad2d2cd9f2bdfceed831652b83bfed7a910d01e
[ "MIT" ]
null
null
null
app.py
jrichardson12/portfolio
aad2d2cd9f2bdfceed831652b83bfed7a910d01e
[ "MIT" ]
null
null
null
app.py
jrichardson12/portfolio
aad2d2cd9f2bdfceed831652b83bfed7a910d01e
[ "MIT" ]
null
null
null
from flask import Flask, render_template from flask_material import Material app = Flask(__name__) Material(app) @app.route('/') def index(): return render_template('splash/splash.html') @app.route('/about') def about(): return render_template('about/about.html') @app.route('/portfolio') def portfolio(): return render_template('portfolio/portfolio.html') @app.route('/blog/<string:blog_id>') def blog(blog_id): return render_template('blog/blog.html', blog_id=blog_id) @app.route('/contact') def contact(): return render_template('contact/contact.html') if __name__ == '__main__': app.run(debug = True)
21.366667
61
0.714509
86
641
5.05814
0.290698
0.193103
0.229885
0
0
0
0
0
0
0
0
0
0.127925
641
29
62
22.103448
0.778175
0
0
0
0
0
0.229329
0.071763
0
0
0
0
0
1
0.238095
false
0
0.095238
0.238095
0.571429
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
1
0
0
4
60d1dc4e93ace964ed8b7e4cf1ebc9423279001f
178
py
Python
test.py
Golobii/Npad
998004ae6042c62ab559223047391b623650eb39
[ "MIT" ]
1
2022-01-06T19:37:26.000Z
2022-01-06T19:37:26.000Z
test.py
Golobii/Npad
998004ae6042c62ab559223047391b623650eb39
[ "MIT" ]
null
null
null
test.py
Golobii/Npad
998004ae6042c62ab559223047391b623650eb39
[ "MIT" ]
1
2022-01-06T19:11:23.000Z
2022-01-06T19:11:23.000Z
def main(): print("Hello World!") test() pozdrav() def test(): print("This is a test") def pozdrav(): print("Hello") if __name__ == '__main__': main()
12.714286
27
0.550562
22
178
4.090909
0.545455
0.222222
0
0
0
0
0
0
0
0
0
0
0.264045
178
13
28
13.692308
0.687023
0
0
0
0
0
0.219101
0
0
0
0
0
0
1
0.3
true
0
0
0
0.3
0.3
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
1
0
0
0
0
0
0
4
60e363dd5e0059d1bb1b225b9bd69bfd009f1d37
4,157
py
Python
tests/posting/test_log2k8s.py
MarkusH/kopf
caaf399c46af0fcb10730eec2db303484d31b38b
[ "MIT" ]
1,038
2019-03-26T16:32:56.000Z
2022-03-27T09:15:03.000Z
tests/posting/test_log2k8s.py
MarkusH/kopf
caaf399c46af0fcb10730eec2db303484d31b38b
[ "MIT" ]
393
2019-03-26T13:43:42.000Z
2020-09-14T13:18:14.000Z
tests/posting/test_log2k8s.py
MarkusH/kopf
caaf399c46af0fcb10730eec2db303484d31b38b
[ "MIT" ]
116
2019-03-31T23:01:09.000Z
2022-03-18T16:44:58.000Z
import logging import pytest from kopf.engines.logging import ObjectLogger, LocalObjectLogger OBJ1 = {'apiVersion': 'group1/version1', 'kind': 'Kind1', 'metadata': {'uid': 'uid1', 'name': 'name1', 'namespace': 'ns1'}} REF1 = {'apiVersion': 'group1/version1', 'kind': 'Kind1', 'uid': 'uid1', 'name': 'name1', 'namespace': 'ns1'} @pytest.mark.parametrize('logfn, event_type', [ ['info', "Normal"], ['warning', "Warning"], ['error', "Error"], ['critical', "Fatal"], ]) async def test_posting_normal_levels(settings, caplog, logstream, logfn, event_type, event_queue, event_queue_loop): logger = ObjectLogger(body=OBJ1, settings=settings) logger_fn = getattr(logger, logfn) logger_fn("hello %s", "world") assert event_queue.qsize() == 1 event1 = event_queue.get_nowait() assert event1.ref == REF1 assert event1.type == event_type assert event1.reason == "Logging" assert event1.message == "hello world" assert caplog.messages == ["hello world"] @pytest.mark.parametrize('logfn, event_type, min_levelno', [ ['debug', "Debug", logging.DEBUG], ['info', "Normal", logging.INFO], ['warning', "Warning", logging.WARNING], ['error', "Error", logging.ERROR], ['critical', "Fatal", logging.CRITICAL], ]) async def test_posting_above_config(settings, caplog, logstream, logfn, event_type, min_levelno, event_queue, event_queue_loop, mocker): logger = ObjectLogger(body=OBJ1, settings=settings) logger_fn = getattr(logger, logfn) settings.posting.level = min_levelno logger_fn("hello %s", "world") settings.posting.level = min_levelno + 1 logger_fn("must not be posted") assert event_queue.qsize() == 1 event1 = event_queue.get_nowait() assert event1.ref == REF1 assert event1.type == event_type assert event1.reason == "Logging" assert event1.message == "hello world" assert caplog.messages == ["hello world", "must not be posted"] @pytest.mark.parametrize('logfn', [ 'debug', ]) async def test_skipping_hidden_levels(settings, caplog, logstream, logfn, event_queue, event_queue_loop): logger = ObjectLogger(body=OBJ1, settings=settings) logger_fn = getattr(logger, logfn) logger_fn("hello %s", "world") logger.info("must be here") assert event_queue.qsize() == 1 # not 2! assert caplog.messages == ["hello world", "must be here"] @pytest.mark.parametrize('logfn', [ 'debug', 'info', 'warning', 'error', 'critical', ]) async def test_skipping_below_config(settings, caplog, logstream, logfn, event_queue, event_queue_loop, mocker): logger = ObjectLogger(body=OBJ1, settings=settings) logger_fn = getattr(logger, logfn) settings.posting.level = 666 logger_fn("hello %s", "world") settings.posting.level = 0 logger.info("must be here") assert event_queue.qsize() == 1 # not 2! assert caplog.messages == ["hello world", "must be here"] @pytest.mark.parametrize('logfn', [ 'debug', 'info', 'warning', 'error', 'critical', ]) async def test_skipping_when_disabled(settings, caplog, logstream, logfn, event_queue, event_queue_loop): logger = LocalObjectLogger(body=OBJ1, settings=settings) logger_fn = getattr(logger, logfn) settings.posting.enabled = False settings.posting.level = 0 logger_fn("hello %s", "world") assert event_queue.qsize() == 0 assert caplog.messages == ["hello world"] @pytest.mark.parametrize('logfn', [ 'debug', 'info', 'warning', 'error', 'critical', ]) async def test_skipping_when_local_with_all_levels(settings, caplog, logstream, logfn, event_queue, event_queue_loop): logger = LocalObjectLogger(body=OBJ1, settings=settings) logger_fn = getattr(logger, logfn) logger_fn("hello %s", "world") assert event_queue.qsize() == 0 assert caplog.messages == ["hello world"]
30.123188
96
0.633871
470
4,157
5.453191
0.180851
0.078034
0.049161
0.060866
0.83769
0.775654
0.699181
0.699181
0.668748
0.647679
0
0.014281
0.225162
4,157
137
97
30.343066
0.781434
0.003127
0
0.714286
0
0
0.15914
0
0
0
0
0
0.190476
1
0
false
0
0.028571
0
0.028571
0
0
0
0
null
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
8811d279032d8704c1798edb7f615ac2e9811e6a
133
py
Python
problog/nnf_formula.py
HEmile/problog
576b6fd305f72b12125111c8d4d62cf8a7bbda0f
[ "Apache-2.0" ]
189
2019-05-27T08:20:10.000Z
2022-03-28T09:29:22.000Z
problog/nnf_formula.py
HEmile/problog
576b6fd305f72b12125111c8d4d62cf8a7bbda0f
[ "Apache-2.0" ]
60
2019-06-11T15:07:48.000Z
2022-03-25T02:31:23.000Z
problog/nnf_formula.py
HEmile/problog
576b6fd305f72b12125111c8d4d62cf8a7bbda0f
[ "Apache-2.0" ]
33
2019-07-03T13:14:24.000Z
2022-02-20T01:07:15.000Z
import warnings warnings.warn( "The class nnf_formula.NNF has been renamed to ddnnf_formula.DDNNF. Please update your code!" )
22.166667
98
0.766917
20
133
5
0.8
0
0
0
0
0
0
0
0
0
0
0
0.165414
133
5
99
26.6
0.900901
0
0
0
0
0
0.691729
0
0
0
0
0
0
1
0
true
0
0.25
0
0.25
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
71578d4a20a54e98162b923e30295d88cf16839e
109
py
Python
Zad_Composite/Rectangle.py
Paarzivall/Wzorce-Projektowe
aa4136f140ad02c0fc0de45709b5a01ca42b417f
[ "MIT" ]
null
null
null
Zad_Composite/Rectangle.py
Paarzivall/Wzorce-Projektowe
aa4136f140ad02c0fc0de45709b5a01ca42b417f
[ "MIT" ]
null
null
null
Zad_Composite/Rectangle.py
Paarzivall/Wzorce-Projektowe
aa4136f140ad02c0fc0de45709b5a01ca42b417f
[ "MIT" ]
null
null
null
from Graphic import Graphic class Rectangle(Graphic): def draw(self): print("Rysuje prostokat")
18.166667
33
0.697248
13
109
5.846154
0.846154
0
0
0
0
0
0
0
0
0
0
0
0.211009
109
6
33
18.166667
0.883721
0
0
0
0
0
0.145455
0
0
0
0
0
0
1
0.25
false
0
0.25
0
0.75
0.25
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
4
716d9bb15ad407c2f20f5485033751970558747b
572
py
Python
predictor/tests/test_init.py
denver1117/predictor
cb1d407725f40912669834c624a94937ea7be46d
[ "MIT" ]
null
null
null
predictor/tests/test_init.py
denver1117/predictor
cb1d407725f40912669834c624a94937ea7be46d
[ "MIT" ]
null
null
null
predictor/tests/test_init.py
denver1117/predictor
cb1d407725f40912669834c624a94937ea7be46d
[ "MIT" ]
1
2021-03-20T23:42:24.000Z
2021-03-20T23:42:24.000Z
""" Test imports """ try: from predictor import * _top_import_error = None except Exception as e: _top_import_error = e try: from predictor import predict _module_import_error = None except Exception as e: _module_import_error = e try: import predictor _package_import_error = None except Exception as e: _package_import_error = e def test_import_predict(): assert _top_import_error == None def test_import_module(): assert _module_import_error == None def test_import_package(): assert _package_import_error == None
17.875
40
0.730769
77
572
5
0.233766
0.257143
0.233766
0.163636
0.402597
0.402597
0.257143
0
0
0
0
0
0.20979
572
31
41
18.451613
0.85177
0.020979
0
0.285714
0
0
0
0
0
0
0
0
0.142857
1
0.142857
false
0
0.714286
0
0.857143
0
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
7179c995782f0c0944115308cb0d20a92bc0d9d0
205
py
Python
tests/test_passwords.py
hagleitn/Openstack-Devstack2
88d3effc70c6479bba276856285dcb3974d76261
[ "Apache-2.0" ]
1
2015-02-21T05:30:46.000Z
2015-02-21T05:30:46.000Z
tests/test_passwords.py
hagleitn/Openstack-Devstack2
88d3effc70c6479bba276856285dcb3974d76261
[ "Apache-2.0" ]
null
null
null
tests/test_passwords.py
hagleitn/Openstack-Devstack2
88d3effc70c6479bba276856285dcb3974d76261
[ "Apache-2.0" ]
null
null
null
from devstack import passwords def test_generate_random(): def check_one(i): p = passwords.generate_random(i) assert len(p) == i for i in range(1, 9): yield check_one, i
18.636364
40
0.62439
31
205
3.967742
0.645161
0.227642
0.146341
0
0
0
0
0
0
0
0
0.013605
0.282927
205
10
41
20.5
0.823129
0
0
0
1
0
0
0
0
0
0
0
0.142857
1
0.285714
false
0.285714
0.142857
0
0.428571
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
1
0
1
0
0
0
0
0
4
719ddc363e324f3d66c757e274e00aafb2383f34
179
py
Python
conftest.py
qntln/logwood
e2393c423363973c19068dc3460290c3a299ded5
[ "Apache-2.0" ]
49
2016-10-29T08:57:44.000Z
2022-03-28T23:19:15.000Z
conftest.py
qntln/logwood
e2393c423363973c19068dc3460290c3a299ded5
[ "Apache-2.0" ]
2
2020-07-05T04:06:40.000Z
2021-08-22T10:10:26.000Z
conftest.py
qntln/logwood
e2393c423363973c19068dc3460290c3a299ded5
[ "Apache-2.0" ]
2
2017-10-30T18:02:06.000Z
2019-02-08T13:08:14.000Z
import logwood.testing import pytest @pytest.fixture(autouse = True) def reset_logwood(): ''' Reset logwood state after each test. ''' yield logwood.testing.reset_state()
13.769231
37
0.73743
23
179
5.652174
0.608696
0.215385
0
0
0
0
0
0
0
0
0
0
0.150838
179
12
38
14.916667
0.855263
0.201117
0
0
0
0
0
0
0
0
0
0
0
1
0.166667
true
0
0.333333
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
71a4f99464e1b2dd38e2006fc8a57b9661a118b0
92
py
Python
add.py
ReyhaneAskari/Git_tutorial
7d63296dcbf953485da32700c3331bd3c6890a48
[ "MIT" ]
1
2022-03-06T08:50:07.000Z
2022-03-06T08:50:07.000Z
add.py
ReyhaneAskari/Git_tutorial
7d63296dcbf953485da32700c3331bd3c6890a48
[ "MIT" ]
null
null
null
add.py
ReyhaneAskari/Git_tutorial
7d63296dcbf953485da32700c3331bd3c6890a48
[ "MIT" ]
1
2018-10-10T01:16:13.000Z
2018-10-10T01:16:13.000Z
def add(): a = 4 b = 2 c = 5 e = 6 return (a + b + c + e) print add()
9.2
26
0.347826
17
92
1.882353
0.705882
0
0
0
0
0
0
0
0
0
0
0.086957
0.5
92
9
27
10.222222
0.608696
0
0
0
0
0
0
0
0
0
0
0
0
0
null
null
0
0
null
null
0.142857
1
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
4
e080ac9ffb498e431ef8301193aa190ceb9ceb8f
88
py
Python
object_detector/__init__.py
VladKha/face_detector
69347af40aed2e6a7f423c9d86a5f44e9f4a5e5f
[ "MIT" ]
1
2018-01-27T21:04:26.000Z
2018-01-27T21:04:26.000Z
object_detector/__init__.py
yikang-he/face_detector
69347af40aed2e6a7f423c9d86a5f44e9f4a5e5f
[ "MIT" ]
31
2018-04-01T16:43:17.000Z
2021-03-18T20:44:56.000Z
object_detector/__init__.py
yikang-he/face_detector
69347af40aed2e6a7f423c9d86a5f44e9f4a5e5f
[ "MIT" ]
4
2019-07-22T03:15:23.000Z
2021-07-20T09:21:27.000Z
import os MODEL_PATH = os.path.join(os.path.split(__file__)[0], 'models', 'sgd.model')
22
76
0.704545
15
88
3.8
0.666667
0.210526
0
0
0
0
0
0
0
0
0
0.0125
0.090909
88
3
77
29.333333
0.7
0
0
0
0
0
0.170455
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
e081709e2c1624e3421223485959e3ab57d75f82
135
py
Python
django/CVE-2021-35042/web/vuln/models.py
nobgr/vulhub
b24a89459fbd98ba76881adb6d4e2fb376792863
[ "MIT" ]
9,681
2017-09-16T12:31:59.000Z
2022-03-31T23:49:31.000Z
django/CVE-2021-35042/web/vuln/models.py
starkxun/vulhub
e5c1b204a6bf1e27d654569ec963329486f230e6
[ "MIT" ]
180
2017-11-01T08:05:07.000Z
2022-03-31T05:26:33.000Z
django/CVE-2021-35042/web/vuln/models.py
starkxun/vulhub
e5c1b204a6bf1e27d654569ec963329486f230e6
[ "MIT" ]
3,399
2017-09-16T12:21:54.000Z
2022-03-31T12:28:48.000Z
from django.db import models # Create your models here. class Collection(models.Model): name = models.CharField(max_length=128)
16.875
43
0.755556
19
135
5.315789
0.842105
0
0
0
0
0
0
0
0
0
0
0.026316
0.155556
135
7
44
19.285714
0.859649
0.177778
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.333333
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
e084df6583b72074c6adb470f4814d7c924bfc0d
1,797
py
Python
accounts/utils.py
DevangS/CoralNet
7c56d4ec95a771718175bd94c3ef51c4095082e3
[ "BSD-2-Clause" ]
4
2015-12-23T05:14:35.000Z
2019-07-09T03:27:10.000Z
accounts/utils.py
DevangS/CoralNet
7c56d4ec95a771718175bd94c3ef51c4095082e3
[ "BSD-2-Clause" ]
3
2015-04-07T02:45:15.000Z
2015-07-01T19:25:10.000Z
accounts/utils.py
DevangS/CoralNet
7c56d4ec95a771718175bd94c3ef51c4095082e3
[ "BSD-2-Clause" ]
2
2016-01-21T17:25:48.000Z
2019-08-29T18:42:14.000Z
from django.conf import settings from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.core.mail import send_mail from django.template.loader import render_to_string from userena import settings as userena_settings from userena.utils import get_protocol def get_imported_user(): return User.objects.get(pk=settings.IMPORTED_USER_ID) def get_robot_user(): return User.objects.get(pk=settings.ROBOT_USER_ID) def get_alleviate_user(): return User.objects.get(pk=settings.ALLEVIATE_USER_ID) def is_imported_user(user): return user.pk == settings.IMPORTED_USER_ID def is_robot_user(user): return user.pk == settings.ROBOT_USER_ID def is_alleviate_user(user): return user.pk == settings.ALLEVIATE_USER_ID def send_activation_email_with_password(userena_signup_obj, password): """ Sends a activation email to the user, along with an automatically generated password that they need to log in. This function only exists because userena/models.py's UserenaSignup.send_activation_email() doesn't have a way to add custom context. """ context= {'user': userena_signup_obj.user, 'protocol': get_protocol(), 'activation_days': userena_settings.USERENA_ACTIVATION_DAYS, 'activation_key': userena_signup_obj.activation_key, 'site': Site.objects.get_current(), 'password': password} subject = render_to_string('userena/emails/activation_email_subject.txt', context) subject = ''.join(subject.splitlines()) message = render_to_string('userena/emails/activation_email_message.txt', context) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [userena_signup_obj.user.email,])
37.4375
77
0.740122
242
1,797
5.239669
0.31405
0.047319
0.066246
0.049685
0.290221
0.290221
0.146688
0
0
0
0
0
0.174736
1,797
48
78
37.4375
0.855024
0.136338
0
0.057143
0
0
0.091387
0.056542
0
0
0
0
0
1
0.2
false
0.057143
0.314286
0.171429
0.685714
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
1
1
1
0
0
4
e0b47b293f965af5fe1d3dea898181b894d1eaa4
64
py
Python
testfixtures/tests/__init__.py
abcdenis/testfixtures
a02097aceea6ffb54de49869e9accc26190c5221
[ "MIT" ]
184
2015-03-18T09:43:35.000Z
2021-08-20T08:22:07.000Z
testfixtures/tests/__init__.py
abcdenis/testfixtures
a02097aceea6ffb54de49869e9accc26190c5221
[ "MIT" ]
131
2015-09-15T15:06:51.000Z
2021-08-24T06:54:01.000Z
testfixtures/tests/__init__.py
abcdenis/testfixtures
a02097aceea6ffb54de49869e9accc26190c5221
[ "MIT" ]
62
2015-06-11T20:42:36.000Z
2021-08-21T01:01:28.000Z
import warnings warnings.simplefilter('default', ImportWarning)
21.333333
47
0.84375
6
64
9
0.833333
0
0
0
0
0
0
0
0
0
0
0
0.0625
64
2
48
32
0.9
0
0
0
0
0
0.109375
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
e0cfeee2cff9819eb771020bdb8cc538e1fa70da
97
py
Python
gimmebio/seqtalk/gimmebio/seqtalk/binary_neurons/__init__.py
Chandrima-04/gimmebio
cb3e66380006d5c5c00ff70bfb87317dd252c312
[ "MIT" ]
3
2020-01-21T23:49:55.000Z
2020-07-29T17:02:30.000Z
gimmebio/seqtalk/gimmebio/seqtalk/binary_neurons/__init__.py
Chandrima-04/gimmebio
cb3e66380006d5c5c00ff70bfb87317dd252c312
[ "MIT" ]
null
null
null
gimmebio/seqtalk/gimmebio/seqtalk/binary_neurons/__init__.py
Chandrima-04/gimmebio
cb3e66380006d5c5c00ff70bfb87317dd252c312
[ "MIT" ]
4
2020-01-21T16:48:17.000Z
2020-03-13T15:34:52.000Z
from .activations import ( StochasticBinaryActivation, DeterministicBinaryActivation, )
16.166667
34
0.783505
5
97
15.2
1
0
0
0
0
0
0
0
0
0
0
0
0.164948
97
5
35
19.4
0.938272
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.25
0
0.25
0
1
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
e0eb00aee477e8df9ac21b0ebe29e974f8745667
573
py
Python
saleor/payment/__init__.py
glosoftgroup/restaurant
5b10a8f5199103e5bee01b45952c9638e63f28af
[ "BSD-3-Clause" ]
2
2017-07-11T12:40:59.000Z
2017-10-18T18:02:46.000Z
saleor/payment/__init__.py
glosoftgroup/restaurant
5b10a8f5199103e5bee01b45952c9638e63f28af
[ "BSD-3-Clause" ]
12
2017-06-19T07:20:41.000Z
2022-03-15T19:03:33.000Z
saleor/payment/__init__.py
glosoftgroup/tenants
a6b229ad1f6d567b7078f83425a532830b71e1bb
[ "BSD-3-Clause" ]
null
null
null
from django.utils.translation import pgettext_lazy class OrderStatus: NEW = 'new' CANCELLED = 'cancelled' SHIPPED = 'shipped' PAYMENT_PENDING = 'payment-pending' FULLY_PAID = 'fully-paid' CHOICES = [ (NEW, pgettext_lazy('order status', 'Processing')), (CANCELLED, pgettext_lazy('order status', 'Cancelled')), (SHIPPED, pgettext_lazy('order status', 'Shipped')), (PAYMENT_PENDING, pgettext_lazy('order status', 'Payment pending')), (FULLY_PAID, pgettext_lazy('order status', 'Fully paid'))]
33.705882
77
0.640489
58
573
6.155172
0.344828
0.201681
0.238095
0.322129
0
0
0
0
0
0
0
0
0.225131
573
16
78
35.8125
0.804054
0
0
0
0
0
0.278276
0
0
0
0
0
0
1
0
false
0
0.076923
0
0.615385
0
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
4
e0ee61b28617533852f019ae6cb53ee2f61c4817
193
py
Python
proxyParttern/Browser.py
manondidi/python-designPattern
0779be858d0afc96acff604243c84a4155398a5a
[ "Apache-2.0" ]
4
2019-12-10T13:32:56.000Z
2022-03-04T11:12:45.000Z
proxyParttern/Browser.py
manondidi/python-designPattern
0779be858d0afc96acff604243c84a4155398a5a
[ "Apache-2.0" ]
null
null
null
proxyParttern/Browser.py
manondidi/python-designPattern
0779be858d0afc96acff604243c84a4155398a5a
[ "Apache-2.0" ]
null
null
null
from proxyParttern.Proxy import Proxy class Browser: def __init__(self, proxy): self.proxy = proxy def request(self): print('浏览器准备访问网络') self.proxy.request()
17.545455
37
0.637306
22
193
5.409091
0.545455
0.226891
0
0
0
0
0
0
0
0
0
0
0.264249
193
10
38
19.3
0.838028
0
0
0
0
0
0.046632
0
0
0
0
0
0
1
0.285714
false
0
0.142857
0
0.571429
0.142857
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
4
1cb5b84cdede8ec2b6fb398d8a99cb23c117ff97
37
py
Python
config.py
jncnn/09-SQL-HW
87ae25ea895f7c57e9c97df8631d7348bef36837
[ "ADSL" ]
null
null
null
config.py
jncnn/09-SQL-HW
87ae25ea895f7c57e9c97df8631d7348bef36837
[ "ADSL" ]
null
null
null
config.py
jncnn/09-SQL-HW
87ae25ea895f7c57e9c97df8631d7348bef36837
[ "ADSL" ]
null
null
null
username="postgres" password="gul21="
18.5
19
0.783784
4
37
7.25
1
0
0
0
0
0
0
0
0
0
0
0.055556
0.027027
37
2
20
18.5
0.75
0
0
0
0
0
0.368421
0
0
0
0
0
0
1
0
false
0.5
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
4
1cb91a51baf9df1a8563070ea25b271c7ef155d2
135
py
Python
golden_config/golden.py
Emin-ahmedoff/golden_installer
bea06b1619bbb786c18ef006de13fa128a099693
[ "MIT" ]
null
null
null
golden_config/golden.py
Emin-ahmedoff/golden_installer
bea06b1619bbb786c18ef006de13fa128a099693
[ "MIT" ]
null
null
null
golden_config/golden.py
Emin-ahmedoff/golden_installer
bea06b1619bbb786c18ef006de13fa128a099693
[ "MIT" ]
null
null
null
import os from requests import get class GoldenConfig(object): REPO_BRANCH = "main" DESTINATION = "./goldenuserbot/"
15
36
0.674074
14
135
6.428571
0.928571
0
0
0
0
0
0
0
0
0
0
0
0.237037
135
9
37
15
0.873786
0
0
0
0
0
0.147059
0
0
0
0
0
0
1
0
false
0
0.4
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
1cb9a8dde70f4420f5f57b161c759a669844241a
149
py
Python
20_loop_pass_statement.py
onowdev/python-selflearning
3d7245de0207a5bfcbce4f7adde60e7316b70a8e
[ "MIT" ]
null
null
null
20_loop_pass_statement.py
onowdev/python-selflearning
3d7245de0207a5bfcbce4f7adde60e7316b70a8e
[ "MIT" ]
null
null
null
20_loop_pass_statement.py
onowdev/python-selflearning
3d7245de0207a5bfcbce4f7adde60e7316b70a8e
[ "MIT" ]
null
null
null
for letter in 'Python': if letter == 'h': pass print("This is Pass Block") print("Current letter", letter) print("Good Job")
21.285714
35
0.577181
20
149
4.3
0.7
0
0
0
0
0
0
0
0
0
0
0
0.281879
149
7
36
21.285714
0.803738
0
0
0
0
0
0.313333
0
0
0
0
0
0
1
0
false
0.333333
0
0
0
0.5
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
1
0
4
1cd29ffca2c3242f17431c87f90a9ce919012135
64
py
Python
glitter/blocks/html/__init__.py
dhamaniasad/django-glitter
b9b0a3d8b49d5d9b840656f84564ba0a6e016f98
[ "BSD-3-Clause" ]
3
2017-06-01T16:22:18.000Z
2018-08-22T21:45:55.000Z
glitter/blocks/html/__init__.py
blancltd/django-glitter
b9b0a3d8b49d5d9b840656f84564ba0a6e016f98
[ "BSD-3-Clause" ]
85
2016-02-25T10:34:03.000Z
2017-04-03T11:07:59.000Z
glitter/blocks/html/__init__.py
blancltd/django-glitter
b9b0a3d8b49d5d9b840656f84564ba0a6e016f98
[ "BSD-3-Clause" ]
1
2016-08-02T08:21:19.000Z
2016-08-02T08:21:19.000Z
default_app_config = 'glitter.blocks.html.apps.HTMLBlockConfig'
32
63
0.84375
8
64
6.5
1
0
0
0
0
0
0
0
0
0
0
0
0.046875
64
1
64
64
0.852459
0
0
0
0
0
0.625
0.625
0
0
0
0
0
1
0
false
0
0
0
0
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
1cda730d0a4dd3f4b3adea5e1a8736a229444582
40
py
Python
2D Crossing Tutorial Folder/content/settings.py
BeanBeing/2D-Crossing-Game-Tutorial
d7d22d72d9c670c79c646e481bf65b170018ecdd
[ "MIT" ]
null
null
null
2D Crossing Tutorial Folder/content/settings.py
BeanBeing/2D-Crossing-Game-Tutorial
d7d22d72d9c670c79c646e481bf65b170018ecdd
[ "MIT" ]
null
null
null
2D Crossing Tutorial Folder/content/settings.py
BeanBeing/2D-Crossing-Game-Tutorial
d7d22d72d9c670c79c646e481bf65b170018ecdd
[ "MIT" ]
null
null
null
screen_width = 1000 screen_height = 500
20
20
0.8
6
40
5
0.833333
0
0
0
0
0
0
0
0
0
0
0.205882
0.15
40
2
21
20
0.676471
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
1cfa9c8d27b8170cbae5e147dcb2fcb2b1ab5431
383
py
Python
setup.py
DoggySmooth/smaef
1f1f5f738bca7a490bb5fafedf748581f42ac308
[ "MIT" ]
null
null
null
setup.py
DoggySmooth/smaef
1f1f5f738bca7a490bb5fafedf748581f42ac308
[ "MIT" ]
null
null
null
setup.py
DoggySmooth/smaef
1f1f5f738bca7a490bb5fafedf748581f42ac308
[ "MIT" ]
null
null
null
#!/usr/bin/env python from setuptools import find_packages, setup setup( packages=find_packages(), scripts=[ 'ammet.py', 'lib/xml2json.py', 'met/scripts/generateGraph.py', 'met/scripts/generateJSON.py', 'met/scripts/generateHTML.py', 'met/scripts/generateXML.py', 'met/scripts/htmlPython.py', 'met/scripts/xmlFormatter.py', 'met/scripts/xmlMerger.py' ] )
19.15
43
0.70235
48
383
5.5625
0.479167
0.131086
0.314607
0
0
0
0
0
0
0
0
0.002994
0.127937
383
19
44
20.157895
0.796407
0.052219
0
0
1
0
0.571823
0.508287
0
0
0
0
0
1
0
true
0
0.066667
0
0.066667
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
1cfdadadf768d17eb5ed3e8b07764167dc672fa9
107
py
Python
scripts/notebook_runner.py
PawarPawan/h2o-v3
cf569a538c9e2ec16ba9fc1a75d14beda8f40c18
[ "Apache-2.0" ]
null
null
null
scripts/notebook_runner.py
PawarPawan/h2o-v3
cf569a538c9e2ec16ba9fc1a75d14beda8f40c18
[ "Apache-2.0" ]
null
null
null
scripts/notebook_runner.py
PawarPawan/h2o-v3
cf569a538c9e2ec16ba9fc1a75d14beda8f40c18
[ "Apache-2.0" ]
null
null
null
import sys sys.path.insert(1, "../") import h2o if __name__ == "__main__": h2o.run_test(sys.argv,None)
17.833333
31
0.672897
17
107
3.705882
0.764706
0
0
0
0
0
0
0
0
0
0
0.032609
0.140187
107
6
31
17.833333
0.652174
0
0
0
0
0
0.101852
0
0
0
0
0
0
1
0
true
0
0.4
0
0.4
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
e808871ce3f843580c48129c9a403588e022beb5
48,034
py
Python
okl4_kernel/okl4_2.1.1-patch.9/tools/magpie-parsers/src/magpieparsers/corba3/IDLLexer.py
CyberQueenMara/baseband-research
e1605537e10c37e161fff1a3416b908c9894f204
[ "MIT" ]
77
2018-12-31T22:12:09.000Z
2021-12-31T22:56:13.000Z
okl4_kernel/okl4_2.1.1-patch.9/tools/magpie-parsers/src/magpieparsers/corba3/IDLLexer.py
CyberQueenMara/baseband-research
e1605537e10c37e161fff1a3416b908c9894f204
[ "MIT" ]
null
null
null
okl4_kernel/okl4_2.1.1-patch.9/tools/magpie-parsers/src/magpieparsers/corba3/IDLLexer.py
CyberQueenMara/baseband-research
e1605537e10c37e161fff1a3416b908c9894f204
[ "MIT" ]
24
2019-01-20T15:51:52.000Z
2021-12-25T18:29:13.000Z
### $ANTLR 2.7.6 (20060903): "idl.g" -> "IDLLexer.py"$ ### import antlr and other modules .. import sys import antlr version = sys.version.split()[0] if version < '2.2.1': False = 0 if version < '2.3': True = not False ### header action >>> from extendAST import extendAST ### header action <<< ### preamble action >>> ### preamble action <<< ### >>>The Literals<<< literals = {} literals[u"switch"] = 61 literals[u"case"] = 62 literals[u"manages"] = 95 literals[u"finder"] = 97 literals[u"interface"] = 7 literals[u"typeprefix"] = 82 literals[u"provides"] = 88 literals[u"exception"] = 71 literals[u"public"] = 23 literals[u"wstring"] = 69 literals[u"default"] = 63 literals[u"sequence"] = 65 literals[u"wchar"] = 54 literals[u"uses"] = 89 literals[u"typeid"] = 81 literals[u"consumes"] = 93 literals[u"void"] = 44 literals[u"inout"] = 75 literals[u"import"] = 80 literals[u"publishes"] = 92 literals[u"boolean"] = 55 literals[u"private"] = 24 literals[u"string"] = 68 literals[u"abstract"] = 5 literals[u"const"] = 27 literals[u"custom"] = 8 literals[u"local"] = 6 literals[u"union"] = 60 literals[u"attribute"] = 84 literals[u"__int64"] = 50 literals[u"oneway"] = 72 literals[u"Object"] = 58 literals[u"fixed"] = 78 literals[u"short"] = 49 literals[u"typedef"] = 42 literals[u"long"] = 47 literals[u"FALSE"] = 41 literals[u"truncatable"] = 21 literals[u"ValueBase"] = 79 literals[u"in"] = 26 literals[u"readonly"] = 83 literals[u"supports"] = 22 literals[u"TRUE"] = 40 literals[u"signed"] = 51 literals[u"enum"] = 64 literals[u"home"] = 94 literals[u"multiple"] = 90 literals[u"octet"] = 56 literals[u"context"] = 77 literals[u"ref"] = 73 literals[u"char"] = 53 literals[u"component"] = 87 literals[u"emits"] = 91 literals[u"getraises"] = 85 literals[u"setraises"] = 86 literals[u"float"] = 45 literals[u"factory"] = 25 literals[u"valuetype"] = 9 literals[u"raises"] = 76 literals[u"out"] = 74 literals[u"any"] = 57 literals[u"double"] = 46 literals[u"int"] = 48 literals[u"primarykey"] = 96 literals[u"eventtype"] = 10 literals[u"unsigned"] = 52 literals[u"struct"] = 59 literals[u"module"] = 16 literals[u"native"] = 43 ### import antlr.Token from antlr import Token ### >>>The Known Token Types <<< SKIP = antlr.SKIP INVALID_TYPE = antlr.INVALID_TYPE EOF_TYPE = antlr.EOF_TYPE EOF = antlr.EOF NULL_TREE_LOOKAHEAD = antlr.NULL_TREE_LOOKAHEAD MIN_USER_TYPE = antlr.MIN_USER_TYPE SEMI = 4 LITERAL_abstract = 5 LITERAL_local = 6 LITERAL_interface = 7 LITERAL_custom = 8 LITERAL_valuetype = 9 LITERAL_eventtype = 10 LBRACK = 11 COMMA = 12 RBRACK = 13 LPAREN = 14 RPAREN = 15 LITERAL_module = 16 LCURLY = 17 RCURLY = 18 COLON = 19 SCOPEOP = 20 LITERAL_truncatable = 21 LITERAL_supports = 22 LITERAL_public = 23 LITERAL_private = 24 LITERAL_factory = 25 LITERAL_in = 26 LITERAL_const = 27 ASSIGN = 28 OR = 29 XOR = 30 AND = 31 LSHIFT = 32 RSHIFT = 33 PLUS = 34 MINUS = 35 STAR = 36 DIV = 37 MOD = 38 TILDE = 39 LITERAL_TRUE = 40 LITERAL_FALSE = 41 LITERAL_typedef = 42 LITERAL_native = 43 LITERAL_void = 44 LITERAL_float = 45 LITERAL_double = 46 LITERAL_long = 47 LITERAL_int = 48 LITERAL_short = 49 ### "__int64" = 50 LITERAL_signed = 51 LITERAL_unsigned = 52 LITERAL_char = 53 LITERAL_wchar = 54 LITERAL_boolean = 55 LITERAL_octet = 56 LITERAL_any = 57 LITERAL_Object = 58 LITERAL_struct = 59 LITERAL_union = 60 LITERAL_switch = 61 LITERAL_case = 62 LITERAL_default = 63 LITERAL_enum = 64 LITERAL_sequence = 65 LT = 66 GT = 67 LITERAL_string = 68 LITERAL_wstring = 69 IDENT = 70 LITERAL_exception = 71 LITERAL_oneway = 72 LITERAL_ref = 73 LITERAL_out = 74 LITERAL_inout = 75 LITERAL_raises = 76 LITERAL_context = 77 LITERAL_fixed = 78 LITERAL_ValueBase = 79 LITERAL_import = 80 LITERAL_typeid = 81 LITERAL_typeprefix = 82 LITERAL_readonly = 83 LITERAL_attribute = 84 LITERAL_getraises = 85 LITERAL_setraises = 86 LITERAL_component = 87 LITERAL_provides = 88 LITERAL_uses = 89 LITERAL_multiple = 90 LITERAL_emits = 91 LITERAL_publishes = 92 LITERAL_consumes = 93 LITERAL_home = 94 LITERAL_manages = 95 LITERAL_primarykey = 96 LITERAL_finder = 97 INT = 98 OCTAL = 99 HEX = 100 STRING_LITERAL = 101 WIDE_STRING_LITERAL = 102 CHAR_LITERAL = 103 WIDE_CHAR_LITERAL = 104 FIXED = 105 FLOAT = 106 QUESTION = 107 DOT = 108 NOT = 109 WS = 110 ALL_TO_NL = 111 PREPROC_DIRECTIVE = 112 SL_COMMENT = 113 ML_COMMENT = 114 ESC = 115 VOCAB = 116 DIGIT = 117 NONZERODIGIT = 118 OCTDIGIT = 119 HEXDIGIT = 120 class Lexer(antlr.CharScanner) : ### user action >>> ### user action <<< def __init__(self, *argv, **kwargs) : antlr.CharScanner.__init__(self, *argv, **kwargs) self.caseSensitiveLiterals = True self.setCaseSensitive(True) self.literals = literals def nextToken(self): while True: try: ### try again .. while True: _token = None _ttype = INVALID_TYPE self.resetText() try: ## for char stream error handling try: ##for lexical error handling la1 = self.LA(1) if False: pass elif la1 and la1 in u';': pass self.mSEMI(True) theRetToken = self._returnToken elif la1 and la1 in u'?': pass self.mQUESTION(True) theRetToken = self._returnToken elif la1 and la1 in u'(': pass self.mLPAREN(True) theRetToken = self._returnToken elif la1 and la1 in u')': pass self.mRPAREN(True) theRetToken = self._returnToken elif la1 and la1 in u'[': pass self.mLBRACK(True) theRetToken = self._returnToken elif la1 and la1 in u']': pass self.mRBRACK(True) theRetToken = self._returnToken elif la1 and la1 in u'{': pass self.mLCURLY(True) theRetToken = self._returnToken elif la1 and la1 in u'}': pass self.mRCURLY(True) theRetToken = self._returnToken elif la1 and la1 in u'|': pass self.mOR(True) theRetToken = self._returnToken elif la1 and la1 in u'^': pass self.mXOR(True) theRetToken = self._returnToken elif la1 and la1 in u'&': pass self.mAND(True) theRetToken = self._returnToken elif la1 and la1 in u',': pass self.mCOMMA(True) theRetToken = self._returnToken elif la1 and la1 in u'=': pass self.mASSIGN(True) theRetToken = self._returnToken elif la1 and la1 in u'!': pass self.mNOT(True) theRetToken = self._returnToken elif la1 and la1 in u'+': pass self.mPLUS(True) theRetToken = self._returnToken elif la1 and la1 in u'-': pass self.mMINUS(True) theRetToken = self._returnToken elif la1 and la1 in u'~': pass self.mTILDE(True) theRetToken = self._returnToken elif la1 and la1 in u'*': pass self.mSTAR(True) theRetToken = self._returnToken elif la1 and la1 in u'%': pass self.mMOD(True) theRetToken = self._returnToken elif la1 and la1 in u'\t\n\r ': pass self.mWS(True) theRetToken = self._returnToken elif la1 and la1 in u'#': pass self.mPREPROC_DIRECTIVE(True) theRetToken = self._returnToken elif la1 and la1 in u'\'': pass self.mCHAR_LITERAL(True) theRetToken = self._returnToken elif la1 and la1 in u'"': pass self.mSTRING_LITERAL(True) theRetToken = self._returnToken elif la1 and la1 in u'123456789': pass self.mINT(True) theRetToken = self._returnToken else: if (self.LA(1)==u'<') and (self.LA(2)==u'<'): pass self.mLSHIFT(True) theRetToken = self._returnToken elif (self.LA(1)==u'>') and (self.LA(2)==u'>'): pass self.mRSHIFT(True) theRetToken = self._returnToken elif (self.LA(1)==u':') and (self.LA(2)==u':'): pass self.mSCOPEOP(True) theRetToken = self._returnToken elif (self.LA(1)==u'/') and (self.LA(2)==u'/'): pass self.mSL_COMMENT(True) theRetToken = self._returnToken elif (self.LA(1)==u'/') and (self.LA(2)==u'*'): pass self.mML_COMMENT(True) theRetToken = self._returnToken elif (self.LA(1)==u'L') and (self.LA(2)==u'\''): pass self.mWIDE_CHAR_LITERAL(True) theRetToken = self._returnToken elif (self.LA(1)==u'L') and (self.LA(2)==u'"'): pass self.mWIDE_STRING_LITERAL(True) theRetToken = self._returnToken elif (self.LA(1)==u'0') and (self.LA(2)==u'X' or self.LA(2)==u'x'): pass self.mHEX(True) theRetToken = self._returnToken elif (self.LA(1)==u'.') and ((self.LA(2) >= u'0' and self.LA(2) <= u'9')): pass self.mFLOAT(True) theRetToken = self._returnToken elif (self.LA(1)==u':') and (True): pass self.mCOLON(True) theRetToken = self._returnToken elif (self.LA(1)==u'.') and (True): pass self.mDOT(True) theRetToken = self._returnToken elif (self.LA(1)==u'<') and (True): pass self.mLT(True) theRetToken = self._returnToken elif (self.LA(1)==u'>') and (True): pass self.mGT(True) theRetToken = self._returnToken elif (self.LA(1)==u'/') and (True): pass self.mDIV(True) theRetToken = self._returnToken elif (self.LA(1)==u'0') and (True): pass self.mOCTAL(True) theRetToken = self._returnToken elif (_tokenSet_0.member(self.LA(1))) and (True): pass self.mIDENT(True) theRetToken = self._returnToken else: self.default(self.LA(1)) if not self._returnToken: raise antlr.TryAgain ### found SKIP token ### option { testLiterals=true } self.testForLiteral(self._returnToken) ### return token to caller return self._returnToken ### handle lexical errors .... except antlr.RecognitionException, e: raise antlr.TokenStreamRecognitionException(e) ### handle char stream errors ... except antlr.CharStreamException,cse: if isinstance(cse, antlr.CharStreamIOException): raise antlr.TokenStreamIOException(cse.io) else: raise antlr.TokenStreamException(str(cse)) except antlr.TryAgain: pass def mSEMI(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = SEMI _saveIndex = 0 pass self.match(';') self.set_return_token(_createToken, _token, _ttype, _begin) def mQUESTION(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = QUESTION _saveIndex = 0 pass self.match('?') self.set_return_token(_createToken, _token, _ttype, _begin) def mLPAREN(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = LPAREN _saveIndex = 0 pass self.match('(') self.set_return_token(_createToken, _token, _ttype, _begin) def mRPAREN(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = RPAREN _saveIndex = 0 pass self.match(')') self.set_return_token(_createToken, _token, _ttype, _begin) def mLBRACK(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = LBRACK _saveIndex = 0 pass self.match('[') self.set_return_token(_createToken, _token, _ttype, _begin) def mRBRACK(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = RBRACK _saveIndex = 0 pass self.match(']') self.set_return_token(_createToken, _token, _ttype, _begin) def mLCURLY(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = LCURLY _saveIndex = 0 pass self.match('{') self.set_return_token(_createToken, _token, _ttype, _begin) def mRCURLY(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = RCURLY _saveIndex = 0 pass self.match('}') self.set_return_token(_createToken, _token, _ttype, _begin) def mOR(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = OR _saveIndex = 0 pass self.match('|') self.set_return_token(_createToken, _token, _ttype, _begin) def mXOR(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = XOR _saveIndex = 0 pass self.match('^') self.set_return_token(_createToken, _token, _ttype, _begin) def mAND(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = AND _saveIndex = 0 pass self.match('&') self.set_return_token(_createToken, _token, _ttype, _begin) def mCOLON(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = COLON _saveIndex = 0 pass self.match(':') self.set_return_token(_createToken, _token, _ttype, _begin) def mCOMMA(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = COMMA _saveIndex = 0 pass self.match(',') self.set_return_token(_createToken, _token, _ttype, _begin) def mDOT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = DOT _saveIndex = 0 pass self.match('.') self.set_return_token(_createToken, _token, _ttype, _begin) def mASSIGN(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = ASSIGN _saveIndex = 0 pass self.match('=') self.set_return_token(_createToken, _token, _ttype, _begin) def mNOT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = NOT _saveIndex = 0 pass self.match('!') self.set_return_token(_createToken, _token, _ttype, _begin) def mLT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = LT _saveIndex = 0 pass self.match('<') self.set_return_token(_createToken, _token, _ttype, _begin) def mLSHIFT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = LSHIFT _saveIndex = 0 pass self.match("<<") self.set_return_token(_createToken, _token, _ttype, _begin) def mGT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = GT _saveIndex = 0 pass self.match('>') self.set_return_token(_createToken, _token, _ttype, _begin) def mRSHIFT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = RSHIFT _saveIndex = 0 pass self.match(">>") self.set_return_token(_createToken, _token, _ttype, _begin) def mDIV(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = DIV _saveIndex = 0 pass self.match('/') self.set_return_token(_createToken, _token, _ttype, _begin) def mPLUS(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = PLUS _saveIndex = 0 pass self.match('+') self.set_return_token(_createToken, _token, _ttype, _begin) def mMINUS(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = MINUS _saveIndex = 0 pass self.match('-') self.set_return_token(_createToken, _token, _ttype, _begin) def mTILDE(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = TILDE _saveIndex = 0 pass self.match('~') self.set_return_token(_createToken, _token, _ttype, _begin) def mSTAR(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = STAR _saveIndex = 0 pass self.match('*') self.set_return_token(_createToken, _token, _ttype, _begin) def mMOD(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = MOD _saveIndex = 0 pass self.match('%') self.set_return_token(_createToken, _token, _ttype, _begin) def mSCOPEOP(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = SCOPEOP _saveIndex = 0 pass self.match("::") self.set_return_token(_createToken, _token, _ttype, _begin) def mWS(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = WS _saveIndex = 0 pass la1 = self.LA(1) if False: pass elif la1 and la1 in u' ': pass self.match(' ') elif la1 and la1 in u'\t': pass self.match('\t') elif la1 and la1 in u'\n': pass self.match('\n') self.newline(); elif la1 and la1 in u'\r': pass self.match('\r') else: self.raise_NoViableAlt(self.LA(1)) _ttype = Token.SKIP; self.set_return_token(_createToken, _token, _ttype, _begin) def mALL_TO_NL(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = ALL_TO_NL _saveIndex = 0 pass while True: if (_tokenSet_1.member(self.LA(1))): pass self.matchNot('\n') else: break self.set_return_token(_createToken, _token, _ttype, _begin) def mPREPROC_DIRECTIVE(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = PREPROC_DIRECTIVE _saveIndex = 0 txt = None pass _saveIndex = self.text.length() self.match('#') self.text.setLength(_saveIndex) pass self.mALL_TO_NL(True) txt = self._returnToken self.preprocessor_directive(txt) _saveIndex = self.text.length() self.match('\n') self.text.setLength(_saveIndex) _ttype = Token.SKIP; self.newline(); self.set_return_token(_createToken, _token, _ttype, _begin) def mSL_COMMENT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = SL_COMMENT _saveIndex = 0 pass _saveIndex = self.text.length() self.match("//") self.text.setLength(_saveIndex) while True: if (_tokenSet_1.member(self.LA(1))): pass self.matchNot('\n') else: break self.match('\n') _ttype = Token.SKIP; self.newline(); self.set_return_token(_createToken, _token, _ttype, _begin) def mML_COMMENT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = ML_COMMENT _saveIndex = 0 pass self.match("/*") while True: if ((self.LA(1)==u'*') and (_tokenSet_2.member(self.LA(2))) and (_tokenSet_2.member(self.LA(3))) and (self.LA(2) != '/')): pass self.match('*') elif (self.LA(1)==u'\n'): pass self.match('\n') self.newline(); elif (_tokenSet_3.member(self.LA(1))): pass self.match(_tokenSet_3) else: break self.match("*/") _ttype = SKIP self.set_return_token(_createToken, _token, _ttype, _begin) def mCHAR_LITERAL(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = CHAR_LITERAL _saveIndex = 0 pass _saveIndex = self.text.length() self.match('\'') self.text.setLength(_saveIndex) if (self.LA(1)==u'\\'): pass self.mESC(False) elif (_tokenSet_4.member(self.LA(1))): pass self.matchNot('\'') else: self.raise_NoViableAlt(self.LA(1)) _saveIndex = self.text.length() self.match('\'') self.text.setLength(_saveIndex) self.set_return_token(_createToken, _token, _ttype, _begin) def mESC(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = ESC _saveIndex = 0 pass _saveIndex = self.text.length() self.match('\\') self.text.setLength(_saveIndex) la1 = self.LA(1) if False: pass elif la1 and la1 in u'n': pass self.match('n') self.text.setLength(_begin) ; self.text.append("\n"); elif la1 and la1 in u't': pass self.match('t') self.text.setLength(_begin) ; self.text.append("\t"); elif la1 and la1 in u'v': pass self.match('v') self.text.setLength(_begin) ; self.text.append("\013"); elif la1 and la1 in u'b': pass self.match('b') self.text.setLength(_begin) ; self.text.append("\b"); elif la1 and la1 in u'r': pass self.match('r') self.text.setLength(_begin) ; self.text.append("\r"); elif la1 and la1 in u'f': pass self.match('f') self.text.setLength(_begin) ; self.text.append("\r"); elif la1 and la1 in u'a': pass self.match('a') self.text.setLength(_begin) ; self.text.append("\007"); elif la1 and la1 in u'\\': pass self.match('\\') self.text.setLength(_begin) ; self.text.append("\\"); elif la1 and la1 in u'?': pass self.match('?') self.text.setLength(_begin) ; self.text.append("?"); elif la1 and la1 in u'\'': pass self.match('\'') self.text.setLength(_begin) ; self.text.append("'"); elif la1 and la1 in u'"': pass self.match('"') self.text.setLength(_begin) ; self.text.append("\""); elif la1 and la1 in u'01234567': pass self.mOCTDIGIT(False) if ((self.LA(1) >= u'0' and self.LA(1) <= u'7')) and ((self.LA(2) >= u'\u0000' and self.LA(2) <= u'\ufffe')) and (True) and (True): pass self.mOCTDIGIT(False) if ((self.LA(1) >= u'0' and self.LA(1) <= u'7')) and ((self.LA(2) >= u'\u0000' and self.LA(2) <= u'\ufffe')) and (True) and (True): pass self.mOCTDIGIT(False) elif ((self.LA(1) >= u'\u0000' and self.LA(1) <= u'\ufffe')) and (True) and (True) and (True): pass else: self.raise_NoViableAlt(self.LA(1)) elif ((self.LA(1) >= u'\u0000' and self.LA(1) <= u'\ufffe')) and (True) and (True) and (True): pass else: self.raise_NoViableAlt(self.LA(1)) realc = str(int(self.text.getString(_begin),8)); self.text.setLength(_begin) ; self.text.append(realc); elif la1 and la1 in u'x': pass _saveIndex = self.text.length() self.match('x') self.text.setLength(_saveIndex) self.mHEXDIGIT(False) if (_tokenSet_5.member(self.LA(1))) and ((self.LA(2) >= u'\u0000' and self.LA(2) <= u'\ufffe')) and (True) and (True): pass self.mHEXDIGIT(False) elif ((self.LA(1) >= u'\u0000' and self.LA(1) <= u'\ufffe')) and (True) and (True) and (True): pass else: self.raise_NoViableAlt(self.LA(1)) realc = str(int(self.text.getString(_begin),16)); self.text.setLength(_begin) ; self.text.append(realc); elif la1 and la1 in u'u': pass _saveIndex = self.text.length() self.match('u') self.text.setLength(_saveIndex) self.mHEXDIGIT(False) if (_tokenSet_5.member(self.LA(1))) and ((self.LA(2) >= u'\u0000' and self.LA(2) <= u'\ufffe')) and (True) and (True): pass self.mHEXDIGIT(False) if (_tokenSet_5.member(self.LA(1))) and ((self.LA(2) >= u'\u0000' and self.LA(2) <= u'\ufffe')) and (True) and (True): pass self.mHEXDIGIT(False) if (_tokenSet_5.member(self.LA(1))) and ((self.LA(2) >= u'\u0000' and self.LA(2) <= u'\ufffe')) and (True) and (True): pass self.mHEXDIGIT(False) elif ((self.LA(1) >= u'\u0000' and self.LA(1) <= u'\ufffe')) and (True) and (True) and (True): pass else: self.raise_NoViableAlt(self.LA(1)) elif ((self.LA(1) >= u'\u0000' and self.LA(1) <= u'\ufffe')) and (True) and (True) and (True): pass else: self.raise_NoViableAlt(self.LA(1)) elif ((self.LA(1) >= u'\u0000' and self.LA(1) <= u'\ufffe')) and (True) and (True) and (True): pass else: self.raise_NoViableAlt(self.LA(1)) realc = str(int(self.text.getString(_begin),16)); self.text.setLength(_begin) ; self.text.append(realc); else: self.raise_NoViableAlt(self.LA(1)) self.set_return_token(_createToken, _token, _ttype, _begin) def mWIDE_CHAR_LITERAL(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = WIDE_CHAR_LITERAL _saveIndex = 0 pass _saveIndex = self.text.length() self.match('L') self.text.setLength(_saveIndex) self.mCHAR_LITERAL(False) self.set_return_token(_createToken, _token, _ttype, _begin) def mSTRING_LITERAL(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = STRING_LITERAL _saveIndex = 0 pass _saveIndex = self.text.length() self.match('"') self.text.setLength(_saveIndex) while True: if (self.LA(1)==u'\\'): pass self.mESC(False) elif (_tokenSet_6.member(self.LA(1))): pass self.matchNot('"') else: break _saveIndex = self.text.length() self.match('"') self.text.setLength(_saveIndex) self.set_return_token(_createToken, _token, _ttype, _begin) def mWIDE_STRING_LITERAL(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = WIDE_STRING_LITERAL _saveIndex = 0 pass _saveIndex = self.text.length() self.match('L') self.text.setLength(_saveIndex) self.mSTRING_LITERAL(False) self.set_return_token(_createToken, _token, _ttype, _begin) def mOCTDIGIT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = OCTDIGIT _saveIndex = 0 pass self.matchRange(u'0', u'7') self.set_return_token(_createToken, _token, _ttype, _begin) def mHEXDIGIT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = HEXDIGIT _saveIndex = 0 pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'0123456789': pass self.matchRange(u'0', u'9') elif la1 and la1 in u'abcdef': pass self.matchRange(u'a', u'f') elif la1 and la1 in u'ABCDEF': pass self.matchRange(u'A', u'F') else: self.raise_NoViableAlt(self.LA(1)) self.set_return_token(_createToken, _token, _ttype, _begin) def mVOCAB(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = VOCAB _saveIndex = 0 pass self.matchRange(u'\3', u'\377') self.set_return_token(_createToken, _token, _ttype, _begin) def mDIGIT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = DIGIT _saveIndex = 0 pass self.matchRange(u'0', u'9') self.set_return_token(_createToken, _token, _ttype, _begin) def mNONZERODIGIT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = NONZERODIGIT _saveIndex = 0 pass self.matchRange(u'1', u'9') self.set_return_token(_createToken, _token, _ttype, _begin) def mHEX(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = HEX _saveIndex = 0 pass if (self.LA(1)==u'0') and (self.LA(2)==u'x'): pass self.match("0x") elif (self.LA(1)==u'0') and (self.LA(2)==u'X'): pass self.match("0X") else: self.raise_NoViableAlt(self.LA(1)) _cnt386= 0 while True: if (_tokenSet_5.member(self.LA(1))): pass self.mHEXDIGIT(False) else: break _cnt386 += 1 if _cnt386 < 1: self.raise_NoViableAlt(self.LA(1)) self.set_return_token(_createToken, _token, _ttype, _begin) def mINT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = INT _saveIndex = 0 pass self.mNONZERODIGIT(False) while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break la1 = self.LA(1) if False: pass elif la1 and la1 in u'.': pass self.match('.') while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break la1 = self.LA(1) if False: pass elif la1 and la1 in u'Ee': pass pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'e': pass self.match('e') elif la1 and la1 in u'E': pass self.match('E') else: self.raise_NoViableAlt(self.LA(1)) la1 = self.LA(1) if False: pass elif la1 and la1 in u'+': pass self.match('+') elif la1 and la1 in u'-': pass self.match('-') elif la1 and la1 in u'0123456789': pass else: self.raise_NoViableAlt(self.LA(1)) _cnt398= 0 while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break _cnt398 += 1 if _cnt398 < 1: self.raise_NoViableAlt(self.LA(1)) _ttype = FLOAT; elif la1 and la1 in u'Dd': pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'd': pass self.match('d') elif la1 and la1 in u'D': pass self.match('D') else: self.raise_NoViableAlt(self.LA(1)) _ttype = FIXED; else: ##<m3> <closing pass _ttype = FLOAT; elif la1 and la1 in u'Ee': pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'e': pass self.match('e') elif la1 and la1 in u'E': pass self.match('E') else: self.raise_NoViableAlt(self.LA(1)) la1 = self.LA(1) if False: pass elif la1 and la1 in u'+': pass self.match('+') elif la1 and la1 in u'-': pass self.match('-') elif la1 and la1 in u'0123456789': pass else: self.raise_NoViableAlt(self.LA(1)) _cnt403= 0 while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break _cnt403 += 1 if _cnt403 < 1: self.raise_NoViableAlt(self.LA(1)) _ttype = FLOAT; elif la1 and la1 in u'Dd': pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'd': pass self.match('d') elif la1 and la1 in u'D': pass self.match('D') else: self.raise_NoViableAlt(self.LA(1)) _ttype = FIXED; else: ##<m3> <closing pass self.set_return_token(_createToken, _token, _ttype, _begin) def mOCTAL(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = OCTAL _saveIndex = 0 pass self.match('0') la1 = self.LA(1) if False: pass elif la1 and la1 in u'0123456789': pass _cnt408= 0 while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break _cnt408 += 1 if _cnt408 < 1: self.raise_NoViableAlt(self.LA(1)) elif la1 and la1 in u'.': pass self.mFLOAT(False) _ttype = FLOAT; elif la1 and la1 in u'Dd': pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'd': pass self.match('d') elif la1 and la1 in u'D': pass self.match('D') else: self.raise_NoViableAlt(self.LA(1)) _ttype = FIXED; else: ##<m3> <closing pass _ttype = INT; self.set_return_token(_createToken, _token, _ttype, _begin) def mFLOAT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = FLOAT _saveIndex = 0 pass self.match('.') _cnt412= 0 while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break _cnt412 += 1 if _cnt412 < 1: self.raise_NoViableAlt(self.LA(1)) la1 = self.LA(1) if False: pass elif la1 and la1 in u'Ee': pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'e': pass self.match('e') elif la1 and la1 in u'E': pass self.match('E') else: self.raise_NoViableAlt(self.LA(1)) la1 = self.LA(1) if False: pass elif la1 and la1 in u'+': pass self.match('+') elif la1 and la1 in u'-': pass self.match('-') elif la1 and la1 in u'0123456789': pass else: self.raise_NoViableAlt(self.LA(1)) _cnt417= 0 while True: if ((self.LA(1) >= u'0' and self.LA(1) <= u'9')): pass self.mDIGIT(False) else: break _cnt417 += 1 if _cnt417 < 1: self.raise_NoViableAlt(self.LA(1)) elif la1 and la1 in u'Dd': pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'd': pass self.match('d') elif la1 and la1 in u'D': pass self.match('D') else: self.raise_NoViableAlt(self.LA(1)) _ttype = FIXED; else: ##<m3> <closing pass self.set_return_token(_createToken, _token, _ttype, _begin) def mIDENT(self, _createToken): _ttype = 0 _token = None _begin = self.text.length() _ttype = IDENT _saveIndex = 0 pass la1 = self.LA(1) if False: pass elif la1 and la1 in u'_': pass self.match('_') elif la1 and la1 in u'abcdefghijklmnopqrstuvwxyz': pass self.matchRange(u'a', u'z') elif la1 and la1 in u'ABCDEFGHIJKLMNOPQRSTUVWXYZ': pass self.matchRange(u'A', u'Z') else: self.raise_NoViableAlt(self.LA(1)) while True: la1 = self.LA(1) if False: pass elif la1 and la1 in u'abcdefghijklmnopqrstuvwxyz': pass self.matchRange(u'a', u'z') elif la1 and la1 in u'ABCDEFGHIJKLMNOPQRSTUVWXYZ': pass self.matchRange(u'A', u'Z') elif la1 and la1 in u'_': pass self.match('_') elif la1 and la1 in u'0123456789': pass self.matchRange(u'0', u'9') else: break ### option { testLiterals=true } _ttype = self.testLiteralsTable(_ttype) self.set_return_token(_createToken, _token, _ttype, _begin) ### generate bit set def mk_tokenSet_0(): data = [0L] * 1025 ### init list data[1] =576460745995190270L return data _tokenSet_0 = antlr.BitSet(mk_tokenSet_0()) ### generate bit set def mk_tokenSet_1(): data = [0L] * 2048 ### init list data[0] =-1025L for x in xrange(1, 1023): data[x] = -1L data[1023] =9223372036854775807L return data _tokenSet_1 = antlr.BitSet(mk_tokenSet_1()) ### generate bit set def mk_tokenSet_2(): data = [0L] * 2048 ### init list data[0] =-8193L for x in xrange(1, 1023): data[x] = -1L data[1023] =9223372036854775807L return data _tokenSet_2 = antlr.BitSet(mk_tokenSet_2()) ### generate bit set def mk_tokenSet_3(): data = [0L] * 2048 ### init list data[0] =-4398046520321L for x in xrange(1, 1023): data[x] = -1L data[1023] =9223372036854775807L return data _tokenSet_3 = antlr.BitSet(mk_tokenSet_3()) ### generate bit set def mk_tokenSet_4(): data = [0L] * 2048 ### init list data[0] =-549755813889L data[1] =-268435457L for x in xrange(2, 1023): data[x] = -1L data[1023] =9223372036854775807L return data _tokenSet_4 = antlr.BitSet(mk_tokenSet_4()) ### generate bit set def mk_tokenSet_5(): data = [0L] * 1025 ### init list data[0] =287948901175001088L data[1] =541165879422L return data _tokenSet_5 = antlr.BitSet(mk_tokenSet_5()) ### generate bit set def mk_tokenSet_6(): data = [0L] * 2048 ### init list data[0] =-17179869185L data[1] =-268435457L for x in xrange(2, 1023): data[x] = -1L data[1023] =9223372036854775807L return data _tokenSet_6 = antlr.BitSet(mk_tokenSet_6()) ### __main__ header action >>> if __name__ == '__main__' : import sys import antlr import IDLLexer ### create lexer - shall read from stdin try: for token in IDLLexer.Lexer(): print token except antlr.TokenStreamException, e: print "error: exception caught while lexing: ", e ### __main__ header action <<<
31.768519
147
0.46084
4,918
48,034
4.309475
0.091501
0.056997
0.036661
0.052137
0.728178
0.719449
0.698877
0.674106
0.663726
0.653157
0
0.052614
0.440105
48,034
1,511
148
31.789543
0.735443
0.017467
0
0.613818
0
0.013091
0.024069
0.002209
0
0
0
0
0
0
null
null
0.149818
0.006545
null
null
0.001455
0
0
0
null
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
1
0
0
0
0
0
4
e80dfa5abd6bb63a9c7743cce54e44615dbcb88f
94
py
Python
inicial/admin.py
soonsam123/Django_dancestude
1c30a6692e758bff9e2f662c175ccafe90fd37d1
[ "MIT" ]
null
null
null
inicial/admin.py
soonsam123/Django_dancestude
1c30a6692e758bff9e2f662c175ccafe90fd37d1
[ "MIT" ]
null
null
null
inicial/admin.py
soonsam123/Django_dancestude
1c30a6692e758bff9e2f662c175ccafe90fd37d1
[ "MIT" ]
null
null
null
from django.contrib import admin from .models import Parceiro admin.site.register(Parceiro)
15.666667
32
0.819149
13
94
5.923077
0.692308
0
0
0
0
0
0
0
0
0
0
0
0.117021
94
5
33
18.8
0.927711
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
e82e8915c6679343ccfb485e43571b606a27a1c5
204
py
Python
cartridge_tax/utils.py
kenbolton/cartridge-tax
9bcb4f06991cd839de3695357063baeaec4cdee1
[ "BSD-2-Clause" ]
1
2015-12-31T17:55:34.000Z
2015-12-31T17:55:34.000Z
cartridge_tax/utils.py
kenbolton/cartridge-tax
9bcb4f06991cd839de3695357063baeaec4cdee1
[ "BSD-2-Clause" ]
null
null
null
cartridge_tax/utils.py
kenbolton/cartridge-tax
9bcb4f06991cd839de3695357063baeaec4cdee1
[ "BSD-2-Clause" ]
null
null
null
def set_salestax(request, tax_type, tax_total): """ Stores the tax type and total in the session. """ request.session["tax_type"] = tax_type request.session["tax_total"] = tax_total
22.666667
49
0.671569
29
204
4.482759
0.413793
0.215385
0.153846
0
0
0
0
0
0
0
0
0
0.210784
204
8
50
25.5
0.807453
0.220588
0
0
0
0
0.120567
0
0
0
0
0
0
1
0.333333
false
0
0
0
0.333333
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
4
1c1ba9bd25e88a6e8f182b4aee15b4c2ef46361e
213
py
Python
jolang/interpreter/file.py
jonatan1609/JoLang
177d18d18b42834c2d624a1050902cc799d7d638
[ "MIT" ]
25
2021-11-04T11:59:18.000Z
2022-03-10T20:20:10.000Z
jolang/interpreter/file.py
jonatan1609/JoLang
177d18d18b42834c2d624a1050902cc799d7d638
[ "MIT" ]
null
null
null
jolang/interpreter/file.py
jonatan1609/JoLang
177d18d18b42834c2d624a1050902cc799d7d638
[ "MIT" ]
1
2022-02-07T21:00:27.000Z
2022-02-07T21:00:27.000Z
class File: def __init__(self, code: str, name: str, ast): self.lines = code.splitlines() self.name = name self.ast = ast def line(self, number): return self.lines[number]
23.666667
50
0.58216
28
213
4.285714
0.5
0.15
0
0
0
0
0
0
0
0
0
0
0.300469
213
8
51
26.625
0.805369
0
0
0
0
0
0
0
0
0
0
0
0
1
0.285714
false
0
0
0.142857
0.571429
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
4
1c635bd108082e9c0d2180e00f89d415020f7fec
559
py
Python
Python Decorators/03_01/args_kwargs.py
Junth19/Learning-Python
724dbade880acbbde00760a38f145a416e744923
[ "MIT" ]
null
null
null
Python Decorators/03_01/args_kwargs.py
Junth19/Learning-Python
724dbade880acbbde00760a38f145a416e744923
[ "MIT" ]
null
null
null
Python Decorators/03_01/args_kwargs.py
Junth19/Learning-Python
724dbade880acbbde00760a38f145a416e744923
[ "MIT" ]
null
null
null
''' Fixed arguments ''' def print_fib(a, b, c): print(a, b, c) print_fib(1, 1, 2) print_fib(1, 1, 2, 3) ''' Using *args ''' def print_fib(a, *args): print(a) print(args) print_fib(1, 1, 2, 3) print_fib(1) ''' Using **kwargs ''' def print_fib(a, **kwargs): print(a) print(kwargs) print_fib(1, se=1, th=2, fo=3, fi=5) print_fib(1) ''' Using *args and **kwargs ''' def print_fib(*args, **kwargs): print(args) print(kwargs) print_fib(1, 1, 2, 3) print_fib(fi=1, se=1, th=2, fo=3) print_fib(1, 1, 2, fo=3, fi=5) print_fib()
12.152174
36
0.583184
108
559
2.888889
0.185185
0.358974
0.230769
0.160256
0.477564
0.314103
0.275641
0.128205
0
0
0
0.069351
0.200358
559
46
37
12.152174
0.628635
0.026834
0
0.52381
0
0
0
0
0
0
0
0
0
1
0.190476
false
0
0
0
0.190476
1
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
1c8ee3028f6af1f940dbc75a24c8d0b561e6c88f
145
py
Python
angrmanagement/logic/__init__.py
Kyle-Kyle/angr-management
6ea65f19d813be510a38f06510b2b2148a6b5000
[ "BSD-2-Clause" ]
2
2022-01-23T21:43:54.000Z
2022-02-02T08:20:20.000Z
angrmanagement/logic/__init__.py
Kyle-Kyle/angr-management
6ea65f19d813be510a38f06510b2b2148a6b5000
[ "BSD-2-Clause" ]
1
2021-12-04T01:11:46.000Z
2021-12-04T01:11:46.000Z
angrmanagement/logic/__init__.py
Kyle-Kyle/angr-management
6ea65f19d813be510a38f06510b2b2148a6b5000
[ "BSD-2-Clause" ]
1
2021-05-17T05:46:19.000Z
2021-05-17T05:46:19.000Z
class GlobalInfo: gui_thread = None main_window = None daemon_inst = None daemon_conn = None headless_plugin_manager = None
18.125
34
0.696552
18
145
5.277778
0.722222
0.210526
0
0
0
0
0
0
0
0
0
0
0.262069
145
7
35
20.714286
0.88785
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
1
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
4
1c9d20476a1b0c00a69a64552d01761e7be8402b
172
py
Python
res/TensorFlowPythonExamples/examples/fill/__init__.py
glistening/ONE-1
cadf3a4da4f4340081862abbd3900af7c4b0e22d
[ "Apache-2.0" ]
null
null
null
res/TensorFlowPythonExamples/examples/fill/__init__.py
glistening/ONE-1
cadf3a4da4f4340081862abbd3900af7c4b0e22d
[ "Apache-2.0" ]
null
null
null
res/TensorFlowPythonExamples/examples/fill/__init__.py
glistening/ONE-1
cadf3a4da4f4340081862abbd3900af7c4b0e22d
[ "Apache-2.0" ]
null
null
null
import tensorflow as tf tf.compat.v1.disable_eager_execution() in_ = tf.compat.v1.placeholder(dtype=tf.int32, shape=(), name="Hole") op_ = tf.compat.v1.fill((3, 4), in_)
24.571429
69
0.72093
29
172
4.103448
0.689655
0.201681
0.252101
0
0
0
0
0
0
0
0
0.045161
0.098837
172
6
70
28.666667
0.722581
0
0
0
0
0
0.023256
0
0
0
0
0
0
1
0
false
0
0.25
0
0.25
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
98dd16873f8d66225facb6d926a87e7ab2656851
30
py
Python
dota_2_win_predictor/__init__.py
ScottKerbey/d2winpredictor
cb77789fb196ea67df9f51fdb331d51e7c7f9ce5
[ "MIT" ]
null
null
null
dota_2_win_predictor/__init__.py
ScottKerbey/d2winpredictor
cb77789fb196ea67df9f51fdb331d51e7c7f9ce5
[ "MIT" ]
null
null
null
dota_2_win_predictor/__init__.py
ScottKerbey/d2winpredictor
cb77789fb196ea67df9f51fdb331d51e7c7f9ce5
[ "MIT" ]
null
null
null
name = "dota_2_win_predictor"
15
29
0.8
5
30
4.2
1
0
0
0
0
0
0
0
0
0
0
0.037037
0.1
30
1
30
30
0.740741
0
0
0
0
0
0.666667
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
c7171ea9b573721ef3642ea3bcd88f2ff766f0a6
61
py
Python
tests/__init__.py
cicwi/PyCorrectedEmissionCT
424449e1879a03cdbb8910c806417962e5b9faff
[ "BSD-3-Clause" ]
3
2020-12-08T17:09:08.000Z
2022-01-21T22:46:56.000Z
tests/__init__.py
cicwi/PyCorrectedEmissionCT
424449e1879a03cdbb8910c806417962e5b9faff
[ "BSD-3-Clause" ]
11
2021-03-19T11:34:34.000Z
2022-03-31T13:22:02.000Z
tests/__init__.py
cicwi/PyCorrectedEmissionCT
424449e1879a03cdbb8910c806417962e5b9faff
[ "BSD-3-Clause" ]
1
2021-03-11T18:27:48.000Z
2021-03-11T18:27:48.000Z
# -*- coding: utf-8 -*- """Unit test package for corrct."""
15.25
35
0.557377
8
61
4.25
1
0
0
0
0
0
0
0
0
0
0
0.02
0.180328
61
3
36
20.333333
0.66
0.852459
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
c724644feff2e466821422e489a086302bc445e9
307
py
Python
Sets/No Idea!.py
adi-797/Python-Hackerrank
b769cb07aca09ac0eda1d81c51b8e277101da870
[ "MIT" ]
3
2018-08-26T15:49:54.000Z
2018-08-31T17:06:48.000Z
Sets/No Idea!.py
adi-797/Python-Hackerrank
b769cb07aca09ac0eda1d81c51b8e277101da870
[ "MIT" ]
null
null
null
Sets/No Idea!.py
adi-797/Python-Hackerrank
b769cb07aca09ac0eda1d81c51b8e277101da870
[ "MIT" ]
null
null
null
# Enter your code here. Read input from STDIN. Print output to STDOUT NM = raw_input() arr = raw_input().split() A = set(raw_input().split()) B = set(raw_input().split()) happiness = 0 for element in arr: if element in A: happiness+=1 elif element in B: happiness-=1 print happiness
23.615385
69
0.661238
49
307
4.061224
0.55102
0.160804
0.19598
0.160804
0
0
0
0
0
0
0
0.012552
0.221498
307
12
70
25.583333
0.820084
0.218241
0
0
0
0
0
0
0
0
0
0.083333
0
0
null
null
0
0
null
null
0.090909
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
1
0
0
0
0
0
0
0
0
4
c7691f789c338d4ce89d0703a3780ade62679fd5
94
py
Python
write_list/apps.py
Songhee95/django_todo_list
18258d8b46194f85a0b5c04c38615f42bdf8c9c5
[ "ISC" ]
null
null
null
write_list/apps.py
Songhee95/django_todo_list
18258d8b46194f85a0b5c04c38615f42bdf8c9c5
[ "ISC" ]
null
null
null
write_list/apps.py
Songhee95/django_todo_list
18258d8b46194f85a0b5c04c38615f42bdf8c9c5
[ "ISC" ]
null
null
null
from django.apps import AppConfig class WriteListConfig(AppConfig): name = 'write_list'
15.666667
33
0.765957
11
94
6.454545
0.909091
0
0
0
0
0
0
0
0
0
0
0
0.159574
94
5
34
18.8
0.898734
0
0
0
0
0
0.106383
0
0
0
0
0
0
1
0
false
0
0.333333
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
c79d66718ba1f8b7bc8bbda94c8778c24f5b6700
220
py
Python
Chapter03/Exercise47/conversion.py
julietteemge/PythonWorkshop
256090f27b317c4846dc64332a5bea95a971e795
[ "MIT" ]
1
2020-05-11T08:51:37.000Z
2020-05-11T08:51:37.000Z
Chapter03/Exercise47/conversion.py
jdevelay/The-Python-Workshop
256090f27b317c4846dc64332a5bea95a971e795
[ "MIT" ]
null
null
null
Chapter03/Exercise47/conversion.py
jdevelay/The-Python-Workshop
256090f27b317c4846dc64332a5bea95a971e795
[ "MIT" ]
null
null
null
def convert_and_sum_list_kwargs(usd_list, **kwargs): total = 0 for amount in usd_list: total += convert_usd_to_aud(amount, **kwargs) return total print(convert_and_sum_list_kwargs([1, 3], rate=0.8))
27.5
53
0.704545
36
220
3.944444
0.555556
0.211268
0.183099
0.239437
0.323944
0
0
0
0
0
0
0.027778
0.181818
220
7
54
31.428571
0.761111
0
0
0
0
0
0
0
0
0
0
0
0
1
0.166667
false
0
0
0
0.333333
0.166667
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
c7b46c2546e05bede059a4a7df61d16906147f66
143
py
Python
Tools/docutils/docutils-0.7/build.py
rtobar/askapsoft
6bae06071d7d24f41abe3f2b7f9ee06cb0a9445e
[ "BSL-1.0", "Apache-2.0", "OpenSSL" ]
1
2020-06-18T08:37:43.000Z
2020-06-18T08:37:43.000Z
Tools/docutils/docutils-0.7/build.py
ATNF/askapsoft
d839c052d5c62ad8a511e58cd4b6548491a6006f
[ "BSL-1.0", "Apache-2.0", "OpenSSL" ]
null
null
null
Tools/docutils/docutils-0.7/build.py
ATNF/askapsoft
d839c052d5c62ad8a511e58cd4b6548491a6006f
[ "BSL-1.0", "Apache-2.0", "OpenSSL" ]
null
null
null
from askapdev.rbuild.builders import Setuptools as Builder builder = Builder() builder.remote_archive = "docutils-0.7.tar.gz" builder.build()
23.833333
58
0.79021
20
143
5.6
0.8
0.375
0.375
0
0
0
0
0
0
0
0
0.015504
0.097902
143
5
59
28.6
0.852713
0
0
0
0
0
0.132867
0
0
0
0
0
0
1
0
false
0
0.25
0
0.25
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
c7c317aadce35a30aa7793d29d9dcf47147f55c2
497
py
Python
replicable/tests/test_delayed.py
philastrophist/replicable
1a5eead7e5a1e149d7818bedf4a985d837436157
[ "MIT" ]
null
null
null
replicable/tests/test_delayed.py
philastrophist/replicable
1a5eead7e5a1e149d7818bedf4a985d837436157
[ "MIT" ]
null
null
null
replicable/tests/test_delayed.py
philastrophist/replicable
1a5eead7e5a1e149d7818bedf4a985d837436157
[ "MIT" ]
null
null
null
def test_getitem_fetches_delayed_array_from_index(): """ spec['a'] """ def test_getitem_logical_indexing_fetches_result_from_param_file(): """ Ensure that `spec[spec['param1'] == 1]` fetches the correct delayed object from the param files """ def test_getitem_multidimensional_logical_indexing_fetches_result_from_param_file(): """ Ensure that `spec[spec['param1'] == 1 | spec['param2'] == 2]` fetches the correct delayed object from the param files """
24.85
121
0.706237
64
497
5.125
0.40625
0.064024
0.128049
0.170732
0.689024
0.689024
0.689024
0.689024
0.689024
0.402439
0
0.01467
0.177062
497
19
122
26.157895
0.787286
0.448692
0
0
0
0
0
0
0
0
0
0
0
1
1
true
0
0
0
1
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
1
0
0
0
1
0
0
4
c7e04ffce186b1ac9b5ae03cc9c7246b2c65fa90
42,814
py
Python
python/client/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_models.py
karanmagdani1/ARO-RP
725dbda2a799e6a7c133515c9990730bbc291c9a
[ "Apache-2.0" ]
null
null
null
python/client/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_models.py
karanmagdani1/ARO-RP
725dbda2a799e6a7c133515c9990730bbc291c9a
[ "Apache-2.0" ]
null
null
null
python/client/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_models.py
karanmagdani1/ARO-RP
725dbda2a799e6a7c133515c9990730bbc291c9a
[ "Apache-2.0" ]
null
null
null
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import msrest.serialization class APIServerProfile(msrest.serialization.Model): """APIServerProfile represents an API server profile. :ivar visibility: API server visibility. Possible values include: "Private", "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :ivar url: The URL to access the cluster API server. :vartype url: str :ivar ip: The IP of the cluster API server. :vartype ip: str """ _attribute_map = { 'visibility': {'key': 'visibility', 'type': 'str'}, 'url': {'key': 'url', 'type': 'str'}, 'ip': {'key': 'ip', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword visibility: API server visibility. Possible values include: "Private", "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :keyword url: The URL to access the cluster API server. :paramtype url: str :keyword ip: The IP of the cluster API server. :paramtype ip: str """ super(APIServerProfile, self).__init__(**kwargs) self.visibility = kwargs.get('visibility', None) self.url = kwargs.get('url', None) self.ip = kwargs.get('ip', None) class CloudErrorBody(msrest.serialization.Model): """CloudErrorBody represents the body of a cloud error. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :vartype code: str :ivar message: A message describing the error, intended to be suitable for display in a user interface. :vartype message: str :ivar target: The target of the particular error. For example, the name of the property in error. :vartype target: str :ivar details: A list of additional details about the error. :vartype details: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CloudErrorBody] """ _attribute_map = { 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, 'target': {'key': 'target', 'type': 'str'}, 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } def __init__( self, **kwargs ): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :paramtype code: str :keyword message: A message describing the error, intended to be suitable for display in a user interface. :paramtype message: str :keyword target: The target of the particular error. For example, the name of the property in error. :paramtype target: str :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CloudErrorBody] """ super(CloudErrorBody, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) self.target = kwargs.get('target', None) self.details = kwargs.get('details', None) class ClusterProfile(msrest.serialization.Model): """ClusterProfile represents a cluster profile. :ivar pull_secret: The pull secret for the cluster. :vartype pull_secret: str :ivar domain: The domain for the cluster. :vartype domain: str :ivar version: The version of the cluster. :vartype version: str :ivar resource_group_id: The ID of the cluster resource group. :vartype resource_group_id: str """ _attribute_map = { 'pull_secret': {'key': 'pullSecret', 'type': 'str'}, 'domain': {'key': 'domain', 'type': 'str'}, 'version': {'key': 'version', 'type': 'str'}, 'resource_group_id': {'key': 'resourceGroupId', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword pull_secret: The pull secret for the cluster. :paramtype pull_secret: str :keyword domain: The domain for the cluster. :paramtype domain: str :keyword version: The version of the cluster. :paramtype version: str :keyword resource_group_id: The ID of the cluster resource group. :paramtype resource_group_id: str """ super(ClusterProfile, self).__init__(**kwargs) self.pull_secret = kwargs.get('pull_secret', None) self.domain = kwargs.get('domain', None) self.version = kwargs.get('version', None) self.resource_group_id = kwargs.get('resource_group_id', None) class ConsoleProfile(msrest.serialization.Model): """ConsoleProfile represents a console profile. :ivar url: The URL to access the cluster console. :vartype url: str """ _attribute_map = { 'url': {'key': 'url', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword url: The URL to access the cluster console. :paramtype url: str """ super(ConsoleProfile, self).__init__(**kwargs) self.url = kwargs.get('url', None) class Display(msrest.serialization.Model): """Display represents the display details of an operation. :ivar provider: Friendly name of the resource provider. :vartype provider: str :ivar resource: Resource type on which the operation is performed. :vartype resource: str :ivar operation: Operation type: read, write, delete, listKeys/action, etc. :vartype operation: str :ivar description: Friendly name of the operation. :vartype description: str """ _attribute_map = { 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, 'operation': {'key': 'operation', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword provider: Friendly name of the resource provider. :paramtype provider: str :keyword resource: Resource type on which the operation is performed. :paramtype resource: str :keyword operation: Operation type: read, write, delete, listKeys/action, etc. :paramtype operation: str :keyword description: Friendly name of the operation. :paramtype description: str """ super(Display, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) self.operation = kwargs.get('operation', None) self.description = kwargs.get('description', None) class IngressProfile(msrest.serialization.Model): """IngressProfile represents an ingress profile. :ivar name: The ingress profile name. :vartype name: str :ivar visibility: Ingress visibility. Possible values include: "Private", "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :ivar ip: The IP of the ingress. :vartype ip: str """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'visibility': {'key': 'visibility', 'type': 'str'}, 'ip': {'key': 'ip', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword name: The ingress profile name. :paramtype name: str :keyword visibility: Ingress visibility. Possible values include: "Private", "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :keyword ip: The IP of the ingress. :paramtype ip: str """ super(IngressProfile, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.visibility = kwargs.get('visibility', None) self.ip = kwargs.get('ip', None) class MasterProfile(msrest.serialization.Model): """MasterProfile represents a master profile. :ivar vm_size: The size of the master VMs. Possible values include: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", "Standard_M128ms". :vartype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :ivar subnet_id: The Azure resource ID of the master subnet. :vartype subnet_id: str :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Possible values include: "Disabled", "Enabled". :vartype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :vartype disk_encryption_set_id: str """ _attribute_map = { 'vm_size': {'key': 'vmSize', 'type': 'str'}, 'subnet_id': {'key': 'subnetId', 'type': 'str'}, 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'str'}, 'disk_encryption_set_id': {'key': 'diskEncryptionSetId', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword vm_size: The size of the master VMs. Possible values include: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", "Standard_M128ms". :paramtype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :keyword subnet_id: The Azure resource ID of the master subnet. :paramtype subnet_id: str :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Possible values include: "Disabled", "Enabled". :paramtype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :paramtype disk_encryption_set_id: str """ super(MasterProfile, self).__init__(**kwargs) self.vm_size = kwargs.get('vm_size', None) self.subnet_id = kwargs.get('subnet_id', None) self.encryption_at_host = kwargs.get('encryption_at_host', None) self.disk_encryption_set_id = kwargs.get('disk_encryption_set_id', None) class NetworkProfile(msrest.serialization.Model): """NetworkProfile represents a network profile. :ivar software_defined_network: The software defined network (SDN) to use when installing the cluster. Possible values include: "OVNKubernetes", "OpenShiftSDN". :vartype software_defined_network: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SoftwareDefinedNetwork :ivar pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. :vartype pod_cidr: str :ivar service_cidr: The CIDR used for OpenShift/Kubernetes Services. :vartype service_cidr: str """ _attribute_map = { 'software_defined_network': {'key': 'softwareDefinedNetwork', 'type': 'str'}, 'pod_cidr': {'key': 'podCidr', 'type': 'str'}, 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword software_defined_network: The software defined network (SDN) to use when installing the cluster. Possible values include: "OVNKubernetes", "OpenShiftSDN". :paramtype software_defined_network: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SoftwareDefinedNetwork :keyword pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. :paramtype pod_cidr: str :keyword service_cidr: The CIDR used for OpenShift/Kubernetes Services. :paramtype service_cidr: str """ super(NetworkProfile, self).__init__(**kwargs) self.software_defined_network = kwargs.get('software_defined_network', None) self.pod_cidr = kwargs.get('pod_cidr', None) self.service_cidr = kwargs.get('service_cidr', None) class Resource(msrest.serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, } def __init__( self, **kwargs ): """ """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar location: Required. The geo-location where the resource lives. :vartype location: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] :keyword location: Required. The geo-location where the resource lives. :paramtype location: str """ super(TrackedResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.location = kwargs['location'] class OpenShiftCluster(TrackedResource): """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar location: Required. The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SystemData :ivar provisioning_state: The cluster provisioning state. Possible values include: "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :ivar cluster_profile: The cluster profile. :vartype cluster_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ClusterProfile :ivar console_profile: The console profile. :vartype console_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ConsoleProfile :ivar service_principal_profile: The cluster service principal profile. :vartype service_principal_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ServicePrincipalProfile :ivar network_profile: The cluster network profile. :vartype network_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.NetworkProfile :ivar master_profile: The cluster master profile. :vartype master_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.MasterProfile :ivar worker_profiles: The cluster worker profiles. :vartype worker_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.WorkerProfile] :ivar apiserver_profile: The cluster API server profile. :vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.APIServerProfile :ivar ingress_profiles: The cluster ingress profiles. :vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.IngressProfile] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, 'system_data': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, } def __init__( self, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] :keyword location: Required. The geo-location where the resource lives. :paramtype location: str :keyword provisioning_state: The cluster provisioning state. Possible values include: "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :keyword cluster_profile: The cluster profile. :paramtype cluster_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ClusterProfile :keyword console_profile: The console profile. :paramtype console_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ConsoleProfile :keyword service_principal_profile: The cluster service principal profile. :paramtype service_principal_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ServicePrincipalProfile :keyword network_profile: The cluster network profile. :paramtype network_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.NetworkProfile :keyword master_profile: The cluster master profile. :paramtype master_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.MasterProfile :keyword worker_profiles: The cluster worker profiles. :paramtype worker_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.WorkerProfile] :keyword apiserver_profile: The cluster API server profile. :paramtype apiserver_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.APIServerProfile :keyword ingress_profiles: The cluster ingress profiles. :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.IngressProfile] """ super(OpenShiftCluster, self).__init__(**kwargs) self.system_data = None self.provisioning_state = kwargs.get('provisioning_state', None) self.cluster_profile = kwargs.get('cluster_profile', None) self.console_profile = kwargs.get('console_profile', None) self.service_principal_profile = kwargs.get('service_principal_profile', None) self.network_profile = kwargs.get('network_profile', None) self.master_profile = kwargs.get('master_profile', None) self.worker_profiles = kwargs.get('worker_profiles', None) self.apiserver_profile = kwargs.get('apiserver_profile', None) self.ingress_profiles = kwargs.get('ingress_profiles', None) class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model): """OpenShiftClusterAdminKubeconfig represents an OpenShift cluster's admin kubeconfig. :ivar kubeconfig: The base64-encoded kubeconfig file. :vartype kubeconfig: str """ _attribute_map = { 'kubeconfig': {'key': 'kubeconfig', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword kubeconfig: The base64-encoded kubeconfig file. :paramtype kubeconfig: str """ super(OpenShiftClusterAdminKubeconfig, self).__init__(**kwargs) self.kubeconfig = kwargs.get('kubeconfig', None) class OpenShiftClusterCredentials(msrest.serialization.Model): """OpenShiftClusterCredentials represents an OpenShift cluster's credentials. :ivar kubeadmin_username: The username for the kubeadmin user. :vartype kubeadmin_username: str :ivar kubeadmin_password: The password for the kubeadmin user. :vartype kubeadmin_password: str """ _attribute_map = { 'kubeadmin_username': {'key': 'kubeadminUsername', 'type': 'str'}, 'kubeadmin_password': {'key': 'kubeadminPassword', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword kubeadmin_username: The username for the kubeadmin user. :paramtype kubeadmin_username: str :keyword kubeadmin_password: The password for the kubeadmin user. :paramtype kubeadmin_password: str """ super(OpenShiftClusterCredentials, self).__init__(**kwargs) self.kubeadmin_username = kwargs.get('kubeadmin_username', None) self.kubeadmin_password = kwargs.get('kubeadmin_password', None) class OpenShiftClusterList(msrest.serialization.Model): """OpenShiftClusterList represents a list of OpenShift clusters. :ivar value: The list of OpenShift clusters. :vartype value: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] :ivar next_link: The link used to get the next page of operations. :vartype next_link: str """ _attribute_map = { 'value': {'key': 'value', 'type': '[OpenShiftCluster]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword value: The list of OpenShift clusters. :paramtype value: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ super(OpenShiftClusterList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) class OpenShiftClusterUpdate(msrest.serialization.Model): """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. :ivar tags: A set of tags. The resource tags. :vartype tags: dict[str, str] :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SystemData :ivar provisioning_state: The cluster provisioning state. Possible values include: "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :ivar cluster_profile: The cluster profile. :vartype cluster_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ClusterProfile :ivar console_profile: The console profile. :vartype console_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ConsoleProfile :ivar service_principal_profile: The cluster service principal profile. :vartype service_principal_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ServicePrincipalProfile :ivar network_profile: The cluster network profile. :vartype network_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.NetworkProfile :ivar master_profile: The cluster master profile. :vartype master_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.MasterProfile :ivar worker_profiles: The cluster worker profiles. :vartype worker_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.WorkerProfile] :ivar apiserver_profile: The cluster API server profile. :vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.APIServerProfile :ivar ingress_profiles: The cluster ingress profiles. :vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.IngressProfile] """ _validation = { 'system_data': {'readonly': True}, } _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, } def __init__( self, **kwargs ): """ :keyword tags: A set of tags. The resource tags. :paramtype tags: dict[str, str] :keyword provisioning_state: The cluster provisioning state. Possible values include: "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :keyword cluster_profile: The cluster profile. :paramtype cluster_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ClusterProfile :keyword console_profile: The console profile. :paramtype console_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ConsoleProfile :keyword service_principal_profile: The cluster service principal profile. :paramtype service_principal_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ServicePrincipalProfile :keyword network_profile: The cluster network profile. :paramtype network_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.NetworkProfile :keyword master_profile: The cluster master profile. :paramtype master_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.MasterProfile :keyword worker_profiles: The cluster worker profiles. :paramtype worker_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.WorkerProfile] :keyword apiserver_profile: The cluster API server profile. :paramtype apiserver_profile: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.APIServerProfile :keyword ingress_profiles: The cluster ingress profiles. :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.IngressProfile] """ super(OpenShiftClusterUpdate, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.system_data = None self.provisioning_state = kwargs.get('provisioning_state', None) self.cluster_profile = kwargs.get('cluster_profile', None) self.console_profile = kwargs.get('console_profile', None) self.service_principal_profile = kwargs.get('service_principal_profile', None) self.network_profile = kwargs.get('network_profile', None) self.master_profile = kwargs.get('master_profile', None) self.worker_profiles = kwargs.get('worker_profiles', None) self.apiserver_profile = kwargs.get('apiserver_profile', None) self.ingress_profiles = kwargs.get('ingress_profiles', None) class Operation(msrest.serialization.Model): """Operation represents an RP operation. :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str :ivar display: The object that describes the operation. :vartype display: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Display :ivar origin: Sources of requests to this operation. Comma separated list with valid values user or system, e.g. "user,system". :vartype origin: str """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'Display'}, 'origin': {'key': 'origin', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that describes the operation. :paramtype display: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Display :keyword origin: Sources of requests to this operation. Comma separated list with valid values user or system, e.g. "user,system". :paramtype origin: str """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) self.origin = kwargs.get('origin', None) class OperationList(msrest.serialization.Model): """OperationList represents an RP operation list. :ivar value: List of operations supported by the resource provider. :vartype value: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Operation] :ivar next_link: The link used to get the next page of operations. :vartype next_link: str """ _attribute_map = { 'value': {'key': 'value', 'type': '[Operation]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword value: List of operations supported by the resource provider. :paramtype value: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Operation] :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ super(OperationList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) class ServicePrincipalProfile(msrest.serialization.Model): """ServicePrincipalProfile represents a service principal profile. :ivar client_id: The client ID used for the cluster. :vartype client_id: str :ivar client_secret: The client secret used for the cluster. :vartype client_secret: str """ _attribute_map = { 'client_id': {'key': 'clientId', 'type': 'str'}, 'client_secret': {'key': 'clientSecret', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword client_id: The client ID used for the cluster. :paramtype client_id: str :keyword client_secret: The client secret used for the cluster. :paramtype client_secret: str """ super(ServicePrincipalProfile, self).__init__(**kwargs) self.client_id = kwargs.get('client_id', None) self.client_secret = kwargs.get('client_secret', None) class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { 'created_by': {'key': 'createdBy', 'type': 'str'}, 'created_by_type': {'key': 'createdByType', 'type': 'str'}, 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CreatedByType :keyword last_modified_at: The type of identity that last modified the resource. :paramtype last_modified_at: ~datetime.datetime """ super(SystemData, self).__init__(**kwargs) self.created_by = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) self.created_at = kwargs.get('created_at', None) self.last_modified_by = kwargs.get('last_modified_by', None) self.last_modified_by_type = kwargs.get('last_modified_by_type', None) self.last_modified_at = kwargs.get('last_modified_at', None) class WorkerProfile(msrest.serialization.Model): """WorkerProfile represents a worker profile. :ivar name: The worker profile name. :vartype name: str :ivar vm_size: The size of the worker VMs. Possible values include: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", "Standard_M128ms". :vartype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :ivar disk_size_gb: The disk size of the worker VMs. :vartype disk_size_gb: int :ivar subnet_id: The Azure resource ID of the worker subnet. :vartype subnet_id: str :ivar count: The number of worker VMs. :vartype count: int :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Possible values include: "Disabled", "Enabled". :vartype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :vartype disk_encryption_set_id: str """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'vm_size': {'key': 'vmSize', 'type': 'str'}, 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, 'subnet_id': {'key': 'subnetId', 'type': 'str'}, 'count': {'key': 'count', 'type': 'int'}, 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'str'}, 'disk_encryption_set_id': {'key': 'diskEncryptionSetId', 'type': 'str'}, } def __init__( self, **kwargs ): """ :keyword name: The worker profile name. :paramtype name: str :keyword vm_size: The size of the worker VMs. Possible values include: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", "Standard_M128ms". :paramtype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :keyword disk_size_gb: The disk size of the worker VMs. :paramtype disk_size_gb: int :keyword subnet_id: The Azure resource ID of the worker subnet. :paramtype subnet_id: str :keyword count: The number of worker VMs. :paramtype count: int :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Possible values include: "Disabled", "Enabled". :paramtype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :paramtype disk_encryption_set_id: str """ super(WorkerProfile, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.vm_size = kwargs.get('vm_size', None) self.disk_size_gb = kwargs.get('disk_size_gb', None) self.subnet_id = kwargs.get('subnet_id', None) self.count = kwargs.get('count', None) self.encryption_at_host = kwargs.get('encryption_at_host', None) self.disk_encryption_set_id = kwargs.get('disk_encryption_set_id', None)
44.275078
140
0.675036
4,896
42,814
5.699142
0.078023
0.022901
0.055048
0.066516
0.778626
0.763861
0.727126
0.710676
0.679927
0.643587
0
0.022217
0.208366
42,814
966
141
44.320911
0.80105
0.583734
0
0.619186
0
0
0.271914
0.055391
0
0
0
0
0
1
0.05814
false
0.005814
0.002907
0
0.188953
0
0
0
0
null
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
c7e37c64592a8ad2434216d68d05285be030fbf4
57
py
Python
backend/shell_setup.py
vaginessa/linky
fe76df7149a0d15818bf5904e66e98a2e9affeb7
[ "BSD-2-Clause" ]
null
null
null
backend/shell_setup.py
vaginessa/linky
fe76df7149a0d15818bf5904e66e98a2e9affeb7
[ "BSD-2-Clause" ]
null
null
null
backend/shell_setup.py
vaginessa/linky
fe76df7149a0d15818bf5904e66e98a2e9affeb7
[ "BSD-2-Clause" ]
null
null
null
import django django.setup() from core.models import *
9.5
25
0.754386
8
57
5.375
0.75
0
0
0
0
0
0
0
0
0
0
0
0.157895
57
5
26
11.4
0.895833
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
1bdd55733dfef0d31b3ad29a43562eb4c8e61840
306
py
Python
src/scs_host/network/__init__.py
south-coast-science/scs_host_rpi
a02afde3fd2e1f2b8c6dc08beef8c74039108a64
[ "MIT" ]
null
null
null
src/scs_host/network/__init__.py
south-coast-science/scs_host_rpi
a02afde3fd2e1f2b8c6dc08beef8c74039108a64
[ "MIT" ]
1
2020-07-13T14:54:08.000Z
2020-11-16T10:11:04.000Z
src/scs_host/network/__init__.py
south-coast-science/scs_host_rpi
a02afde3fd2e1f2b8c6dc08beef8c74039108a64
[ "MIT" ]
2
2017-11-07T16:59:02.000Z
2019-09-29T15:39:37.000Z
""" Created on 16 Apr 2017 @author: Bruno Beloff (bruno.beloff@southcoastscience.com) """ from scs_host.network.wpa_supplicant_file import WPASupplicantFile # -------------------------------------------------------------------------------------------------------------------- WPASupplicantFile.init()
23.538462
118
0.48366
23
306
6.304348
0.869565
0.151724
0
0
0
0
0
0
0
0
0
0.021201
0.075163
306
12
119
25.5
0.491166
0.653595
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
4014469fd89ee83ef6ca8c06966528fa1486b594
180
py
Python
globals/__init__.py
sector84/vipnet-coordinator-hw-config-parser
9221ebffa447e916311f324004d1a8c670150632
[ "MIT" ]
null
null
null
globals/__init__.py
sector84/vipnet-coordinator-hw-config-parser
9221ebffa447e916311f324004d1a8c670150632
[ "MIT" ]
null
null
null
globals/__init__.py
sector84/vipnet-coordinator-hw-config-parser
9221ebffa447e916311f324004d1a8c670150632
[ "MIT" ]
null
null
null
from .params import GeneralData from .utils import convert_mask_to_str general_params = GeneralData.get_instance() __all__ = [ 'general_params', 'convert_mask_to_str', ]
18
43
0.766667
23
180
5.434783
0.565217
0.176
0.208
0.256
0
0
0
0
0
0
0
0
0.15
180
9
44
20
0.816993
0
0
0
0
0
0.183333
0
0
0
0
0
0
1
0
false
0
0.285714
0
0.285714
0
1
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
4044e125dde14ab3c7981d3f1170c00792db09ba
1,064
py
Python
slap_dj/app/migrations/0016_auto_20201218_0902.py
FuckBrains/slap
dfd5ae095980920c12ba1451926aa5b819997a47
[ "BSD-3-Clause" ]
null
null
null
slap_dj/app/migrations/0016_auto_20201218_0902.py
FuckBrains/slap
dfd5ae095980920c12ba1451926aa5b819997a47
[ "BSD-3-Clause" ]
null
null
null
slap_dj/app/migrations/0016_auto_20201218_0902.py
FuckBrains/slap
dfd5ae095980920c12ba1451926aa5b819997a47
[ "BSD-3-Clause" ]
1
2021-07-09T15:34:52.000Z
2021-07-09T15:34:52.000Z
# Generated by Django 3.1.3 on 2020-12-18 09:02 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('app', '0015_auto_20201217_0239'), ] operations = [ migrations.AlterField( model_name='youtubevideo', name='comment_count', field=models.BigIntegerField(null=True), ), migrations.AlterField( model_name='youtubevideo', name='dislike_count', field=models.BigIntegerField(null=True), ), migrations.AlterField( model_name='youtubevideo', name='favorite_count', field=models.BigIntegerField(null=True), ), migrations.AlterField( model_name='youtubevideo', name='like_count', field=models.BigIntegerField(null=True), ), migrations.AlterField( model_name='youtubevideo', name='view_count', field=models.BigIntegerField(null=True), ), ]
27.282051
52
0.572368
94
1,064
6.340426
0.414894
0.167785
0.209732
0.243289
0.704698
0.704698
0.563758
0.563758
0.563758
0.563758
0
0.042759
0.318609
1,064
38
53
28
0.77931
0.042293
0
0.625
1
0
0.143559
0.022616
0
0
0
0
0
1
0
false
0
0.03125
0
0.125
0
0
0
0
null
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
4057bb34b4bba3c8b2fe6e137c2ab3e85a72bf01
695
py
Python
build/lib/auto_instr/__init__.py
arvind0790/auto_instr
6b4ff1c535a8124c6f8e92e5dddd71f9101f8c24
[ "MIT" ]
1
2018-07-26T09:08:18.000Z
2018-07-26T09:08:18.000Z
auto_instr/__init__.py
arvind0790/auto_instr
6b4ff1c535a8124c6f8e92e5dddd71f9101f8c24
[ "MIT" ]
null
null
null
auto_instr/__init__.py
arvind0790/auto_instr
6b4ff1c535a8124c6f8e92e5dddd71f9101f8c24
[ "MIT" ]
1
2019-07-15T13:19:01.000Z
2019-07-15T13:19:01.000Z
from .adapter import gpib from .adapter import serial from .adapter import lan from .adapter import lan_debug from .adapter import usb from .adapter import usb_debug from .adapter import enumerate from .dpo7104 import scope from .tempforce import tempforce from .tektronixafg3102 import tekafg3102 from .agilent3631a import agi3631 from .keithley2400 import ke2400 from .keithley2000 import ke2000 from .datalog import datalog from .hpmm3458A import hp3458 from .keysight33600afg import keyafg33600 from .agilent34405dmm import agi34405 from .keithley2600 import ke2600 from .infiniium80000 import infi_scope from .infiniium90804A import infi90804 from .psw_800 import PSW800
33.095238
42
0.821583
88
695
6.443182
0.409091
0.135802
0.209877
0.070547
0
0
0
0
0
0
0
0.157095
0.148201
695
21
43
33.095238
0.800676
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
40856b23e7d32e221d918a15e2e1200fb813b9ee
431
py
Python
__init__.py
OpenVoiceOS/skill-ovos-common-play
71ca166cdd4262973c3f93d4a24ee3ede6598695
[ "Apache-2.0" ]
null
null
null
__init__.py
OpenVoiceOS/skill-ovos-common-play
71ca166cdd4262973c3f93d4a24ee3ede6598695
[ "Apache-2.0" ]
2
2021-08-24T08:44:01.000Z
2021-09-06T20:17:31.000Z
__init__.py
JarbasSkills/skill-better-playback-control
71ca166cdd4262973c3f93d4a24ee3ede6598695
[ "Apache-2.0" ]
2
2021-03-30T20:10:43.000Z
2021-04-02T01:49:39.000Z
from ovos_utils.log import LOG from ovos_workshop.skills import OVOSSkill class OCPSkill(OVOSSkill): def initialize(self): # TODO setup the plugin in mycroft.conf if needed # allows distributing OCP via skill stores LOG.info("This skill has been replaced with a plugin, " "please see https://github.com/OpenVoiceOS/ovos-ocp-audio-plugin") def create_skill(): return OCPSkill()
26.9375
83
0.696056
58
431
5.12069
0.758621
0.053872
0
0
0
0
0
0
0
0
0
0
0.227378
431
15
84
28.733333
0.891892
0.204176
0
0
0
0
0.314706
0
0
0
0
0.066667
0
1
0.25
false
0
0.25
0.125
0.75
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
1
0
0
0
1
1
0
0
4
409d446d9db99115df8b5da2c7fe0f759d1ea9c1
182
py
Python
asym_rlpo/utils/device.py
abaisero/asym-porl
8a76d920e51d783bbeeeea3cd2b02efffbb33c72
[ "MIT" ]
2
2021-08-24T22:41:36.000Z
2021-10-31T01:55:37.000Z
asym_rlpo/utils/device.py
abaisero/asym-porl
8a76d920e51d783bbeeeea3cd2b02efffbb33c72
[ "MIT" ]
null
null
null
asym_rlpo/utils/device.py
abaisero/asym-porl
8a76d920e51d783bbeeeea3cd2b02efffbb33c72
[ "MIT" ]
1
2021-10-13T12:27:40.000Z
2021-10-13T12:27:40.000Z
import torch def get_device(device: str) -> torch.device: if device == 'auto': device = 'cuda' if torch.cuda.is_available() else 'cpu' return torch.device(device)
20.222222
63
0.653846
25
182
4.68
0.56
0.205128
0
0
0
0
0
0
0
0
0
0
0.214286
182
8
64
22.75
0.818182
0
0
0
0
0
0.06044
0
0
0
0
0
0
1
0.2
false
0
0.2
0
0.6
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
4
40b706607a94ecda36a735a91b3fd55ddf726766
203
py
Python
src/negotiating_agent/venv/lib/python3.8/site-packages/geniusweb/events/ProtocolEvent.py
HahaBill/CollaborativeAI
f771cd2f34774c74c58e49a7e983d6244ea35eff
[ "MIT" ]
1
2022-02-17T19:14:46.000Z
2022-02-17T19:14:46.000Z
src/negotiating_agent/venv/lib/python3.8/site-packages/geniusweb/events/ProtocolEvent.py
HahaBill/CollaborativeAI
f771cd2f34774c74c58e49a7e983d6244ea35eff
[ "MIT" ]
null
null
null
src/negotiating_agent/venv/lib/python3.8/site-packages/geniusweb/events/ProtocolEvent.py
HahaBill/CollaborativeAI
f771cd2f34774c74c58e49a7e983d6244ea35eff
[ "MIT" ]
null
null
null
from geniusweb.events.AbstractEvent import AbstractEvent class ProtocolEvent (AbstractEvent): ''' an event triggered by the protocol. ''' def ProtocolEvent(self, now:int): super().__init__(now)
20.3
56
0.753695
23
203
6.478261
0.826087
0
0
0
0
0
0
0
0
0
0
0
0.137931
203
9
57
22.555556
0.851429
0.172414
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.25
0
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
4
40c9513ca5976176b851554d8c44ea508d46fdf2
475
py
Python
figures/pagination.py
groovetch/edx-figures
a69fc1195c05176ac7dae90b337dd77f4bd9679f
[ "MIT" ]
43
2018-05-29T20:01:25.000Z
2021-12-02T09:43:17.000Z
figures/pagination.py
groovetch/edx-figures
a69fc1195c05176ac7dae90b337dd77f4bd9679f
[ "MIT" ]
330
2018-05-30T17:06:15.000Z
2022-03-16T15:52:22.000Z
figures/pagination.py
groovetch/edx-figures
a69fc1195c05176ac7dae90b337dd77f4bd9679f
[ "MIT" ]
40
2018-10-06T00:15:58.000Z
2022-02-14T12:44:45.000Z
'''Paginatiors for Figures ''' from __future__ import absolute_import from rest_framework.pagination import LimitOffsetPagination class FiguresLimitOffsetPagination(LimitOffsetPagination): '''Custom Figures paginator to make the number of records returned consistent ''' default_limit = 20 class FiguresKiloPagination(LimitOffsetPagination): '''Custom Figures paginator to make the number of records returned consistent ''' default_limit = 1000
25
81
0.783158
48
475
7.583333
0.583333
0.148352
0.186813
0.236264
0.532967
0.532967
0.532967
0.532967
0.532967
0.532967
0
0.015038
0.16
475
18
82
26.388889
0.897243
0.385263
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.333333
0
1
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
40cac93a284359b1c89d9db92ecc27f658924f4a
93
py
Python
cmddocs/version.py
noqqe/cmddocs
5cc61ec36e153c380f81b60717931eb8ff428b98
[ "MIT" ]
66
2015-01-05T02:42:15.000Z
2022-03-24T00:25:55.000Z
cmddocs/version.py
noqqe/cmddocs
5cc61ec36e153c380f81b60717931eb8ff428b98
[ "MIT" ]
28
2015-01-06T21:44:14.000Z
2016-11-15T14:38:29.000Z
cmddocs/version.py
noqqe/cmddocs
5cc61ec36e153c380f81b60717931eb8ff428b98
[ "MIT" ]
12
2015-01-06T21:59:09.000Z
2018-11-04T06:35:09.000Z
from pkg_resources import get_distribution __version__ = get_distribution('cmddocs').version
31
49
0.860215
11
93
6.636364
0.727273
0.410959
0
0
0
0
0
0
0
0
0
0
0.075269
93
2
50
46.5
0.848837
0
0
0
0
0
0.075269
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
40cff2df304d99e8dfd7dc4d31338786cd1bf1bb
490
py
Python
EGGS_labrad/clients/script_scanner_gui/__init__.py
EGGS-Experiment/EGGS_Control
c29b3ab0e30dcb6e01d1ca3212ac64ad1506143b
[ "MIT" ]
2
2021-12-26T05:00:54.000Z
2021-12-30T17:15:49.000Z
EGGS_labrad/clients/script_scanner_gui/__init__.py
EGGS-Experiment/EGGS_Control
c29b3ab0e30dcb6e01d1ca3212ac64ad1506143b
[ "MIT" ]
null
null
null
EGGS_labrad/clients/script_scanner_gui/__init__.py
EGGS-Experiment/EGGS_Control
c29b3ab0e30dcb6e01d1ca3212ac64ad1506143b
[ "MIT" ]
null
null
null
""" Script Scanner GUI can be broken into 2 parts: the TreeView and Scripting. TreeView comprises everything that involves experimental parameters. Scripting comprises everything that involves scripts and experimental sequences. "Views" contains all the GUI files (stores as .ui types). "connect.py" is a wrapper for a LabRAD connection that additionally managers server and client connections, as well as context-related stuff. """ from .script_scanner_gui import script_scanner_gui
40.833333
83
0.808163
69
490
5.681159
0.695652
0.09949
0.122449
0.158163
0
0
0
0
0
0
0
0.002387
0.144898
490
11
84
44.545455
0.933174
0.87551
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
90692882a79f4eef6affd5d58e67200f97d7366a
301
py
Python
venv/Lib/site-packages/tensorflow/keras/estimator/__init__.py
caiovini/Image_reader_api
7fae630a17195d3415eb739278ef21a3b58cae76
[ "MIT" ]
null
null
null
venv/Lib/site-packages/tensorflow/keras/estimator/__init__.py
caiovini/Image_reader_api
7fae630a17195d3415eb739278ef21a3b58cae76
[ "MIT" ]
null
null
null
venv/Lib/site-packages/tensorflow/keras/estimator/__init__.py
caiovini/Image_reader_api
7fae630a17195d3415eb739278ef21a3b58cae76
[ "MIT" ]
null
null
null
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/tools/api/generator/create_python_api.py script. """Home of estimator related functions. """ from __future__ import print_function from tensorflow.python.estimator.estimator_lib import model_to_estimator del print_function
25.083333
75
0.817276
42
301
5.595238
0.738095
0.110638
0
0
0
0
0
0
0
0
0
0
0.112957
301
11
76
27.363636
0.88015
0.518272
0
0
1
0
0
0
0
0
0
0
0
1
0
true
0
0.666667
0
0.666667
0.666667
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
1
0
4
909f744e0ad8fafe18e0ab5f0a46c3392bf5bfa5
121
py
Python
__init__.py
lkrzysiak/django-universal-model-repository
c21c44fe6822ff1ae439da5ddfa152a2e269acaf
[ "MIT" ]
null
null
null
__init__.py
lkrzysiak/django-universal-model-repository
c21c44fe6822ff1ae439da5ddfa152a2e269acaf
[ "MIT" ]
null
null
null
__init__.py
lkrzysiak/django-universal-model-repository
c21c44fe6822ff1ae439da5ddfa152a2e269acaf
[ "MIT" ]
null
null
null
from models import SoftDeleteManager, DataAccessObject, DAO, model, model_to_json, \ map_collection, group_collection
60.5
84
0.826446
14
121
6.857143
0.857143
0
0
0
0
0
0
0
0
0
0
0
0.115702
121
2
85
60.5
0.897196
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
90ad3aea8ee018b79091cadeabe37604f7d1518d
14,290
py
Python
tests/unit/test_mongodb_provider.py
delgod/mongodb-k8s-operator
c6f23b282b72cd0bf39bee03a09b0d0ae7494b74
[ "Apache-2.0" ]
1
2022-03-28T16:53:29.000Z
2022-03-28T16:53:29.000Z
tests/unit/test_mongodb_provider.py
delgod/mongodb-k8s-operator
c6f23b282b72cd0bf39bee03a09b0d0ae7494b74
[ "Apache-2.0" ]
null
null
null
tests/unit/test_mongodb_provider.py
delgod/mongodb-k8s-operator
c6f23b282b72cd0bf39bee03a09b0d0ae7494b74
[ "Apache-2.0" ]
null
null
null
# Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. import unittest from unittest.mock import patch from ops.testing import Harness from pymongo.errors import ConfigurationError, ConnectionFailure, OperationFailure from charm import MongoDBCharm from tests.unit.helpers import patch_network_get PYMONGO_EXCEPTIONS = [ (ConnectionFailure("error message"), ConnectionFailure), (ConfigurationError("error message"), ConfigurationError), (OperationFailure("error message"), OperationFailure), ] PEER_ADDR = {"private-address": "127.4.5.6"} RELATION_EVENTS = ["joined", "changed", "departed"] DEPARTED_IDS = [None, 0] class TestMongoProvider(unittest.TestCase): @patch_network_get(private_address="1.1.1.1") def setUp(self): self.harness = Harness(MongoDBCharm) mongo_resource = { "registrypath": "mongo:4.4", } self.harness.add_oci_resource("mongodb-image", mongo_resource) self.harness.begin() self.harness.add_relation("database-peers", "mongodb-peers") self.harness.set_leader(True) self.charm = self.harness.charm self.addCleanup(self.harness.cleanup) @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider.oversee_users") def test_relation_event_db_not_initialised(self, oversee_users, defer): """Tests no database relations are handled until the database is initialised. Users should not be "overseen" until the database has been initialised, no matter the event hook (departed, joined, updated) """ # presets self.harness.set_leader(True) relation_id = self.harness.add_relation("database", "consumer") for relation_event in RELATION_EVENTS: if relation_event == "joined": self.harness.add_relation_unit(relation_id, "consumer/0") elif relation_event == "changed": self.harness.update_relation_data(relation_id, "consumer/0", PEER_ADDR) else: self.harness.remove_relation_unit(relation_id, "consumer/0") oversee_users.assert_not_called() defer.assert_not_called() @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider.oversee_users") def test_relation_event_oversee_users_mongo_failure(self, oversee_users, defer): """Tests the errors related to pymongo when overseeing users result in a defer.""" # presets self.harness.set_leader(True) self.harness.charm.app_data["db_initialised"] = "True" relation_id = self.harness.add_relation("database", "consumer") for exception, expected_raise in PYMONGO_EXCEPTIONS: oversee_users.side_effect = exception for relation_event in RELATION_EVENTS: if relation_event == "joined": self.harness.add_relation_unit(relation_id, "consumer/0") elif relation_event == "changed": self.harness.update_relation_data(relation_id, "consumer/0", PEER_ADDR) else: self.harness.remove_relation_unit(relation_id, "consumer/0") defer.assert_called() # oversee_users raises AssertionError when unable to attain users from relation @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider.oversee_users") def test_relation_event_oversee_users_fails_to_get_relation(self, oversee_users, defer): """Verifies that when users are formatted incorrectly an assertion error is raised.""" # presets self.harness.set_leader(True) self.harness.charm.app_data["db_initialised"] = "True" relation_id = self.harness.add_relation("database", "consumer") # AssertionError is raised when unable to attain users from relation (due to name # formatting) oversee_users.side_effect = AssertionError with self.assertRaises(AssertionError): for relation_event in RELATION_EVENTS: if relation_event == "joined": self.harness.add_relation_unit(relation_id, "consumer/0") elif relation_event == "changed": self.harness.update_relation_data(relation_id, "consumer/0", PEER_ADDR) else: self.harness.remove_relation_unit(relation_id, "consumer/0") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_get_users_failure(self, connection): """Verifies that when unable to retrieve users from mongod an exception is raised.""" for dep_id in DEPARTED_IDS: for exception, expected_raise in PYMONGO_EXCEPTIONS: connection.return_value.__enter__.return_value.get_users.side_effect = exception with self.assertRaises(expected_raise): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_drop_user_failure(self, connection, relation_users): """Verifies that when unable to drop users from mongod an exception is raised.""" # presets, such that there is a need to drop users. relation_users.return_value = {"relation-user1"} connection.return_value.__enter__.return_value.get_users.return_value = { "relation-user1", "relation-user2", } for dep_id in DEPARTED_IDS: for exception, expected_raise in PYMONGO_EXCEPTIONS: connection.return_value.__enter__.return_value.drop_user.side_effect = exception with self.assertRaises(expected_raise): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_get_config_failure(self, connection, relation_users): """Verifies that when users do not match necessary schema an AssertionError is raised.""" # presets, such that the need to create user relations is triggered. Further presets # designed such that relation users will not match due to not following schema # "relation-username" relation_users.return_value = {"user1", "user2"} connection.return_value.__enter__.return_value.get_users.return_value = {"user1"} for dep_id in DEPARTED_IDS: with self.assertRaises(AssertionError): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._set_relation") @patch("charm.MongoDBProvider._get_config") @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_no_config_database( self, connection, relation_users, get_config, set_relation ): """Verifies when the config for a user has no database that they are not created.""" # presets, such that the need to create user relations is triggered relation_users.return_value = {"relation-user1", "relation-user2"} connection.return_value.__enter__.return_value.get_users.return_value = {"relation-user1"} get_config.return_value.database = None for dep_id in DEPARTED_IDS: self.harness.charm.client_relations.oversee_users(dep_id) connection.return_value.__enter__.return_value.create_user.assert_not_called() set_relation.assert_not_called() @patch("charm.MongoDBProvider._set_relation") @patch("charm.MongoDBProvider._get_config") @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_create_user_failure( self, connection, relation_users, get_config, set_relation ): """Verfies when user creation fails an exception is raised and no relations are set.""" # presets, such that the need to create user relations is triggered relation_users.return_value = {"relation-user1", "relation-user2"} connection.return_value.__enter__.return_value.get_users.return_value = {"relation-user1"} for dep_id in DEPARTED_IDS: for exception, expected_raise in PYMONGO_EXCEPTIONS: connection.return_value.__enter__.return_value.create_user.side_effect = exception with self.assertRaises(expected_raise): self.harness.charm.client_relations.oversee_users(dep_id) set_relation.assert_not_called() @patch("charm.MongoDBProvider._get_config") @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_set_relation_failure(self, connection, relation_users, get_config): """Verifies that when adding a user with an invalid name that an exception is raised.""" # presets, such that the need to create user relations is triggered and user naming such # that setting relation users will fail since they do not follow the schema # "relation-username" relation_users.return_value = {"user1", "user2"} connection.return_value.__enter__.return_value.get_users.return_value = {"user1"} get_config.return_value.username = "user1" for dep_id in DEPARTED_IDS: # getting usernames raises AssertionError when usernames do not follow correct format with self.assertRaises(AssertionError): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_update_get_config_failure(self, connection, relation_users): """Verifies that when updating a user with an invalid name that an exception is raised.""" # presets, such that the need to update user relations is triggered and user naming such # that setting relation users will fail since they do not follow the schema # "relation-username" relation_users.return_value = {"user1"} connection.return_value.__enter__.return_value.get_users.return_value = {"user1"} for dep_id in DEPARTED_IDS: with self.assertRaises(AssertionError): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._get_config") @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_update_user_failure(self, connection, relation_users, get_config): """Verifies that when updating users fails an exception is raised.""" # presets, such that the need to update user relations is triggered relation_users.return_value = {"relation-user1"} connection.return_value.__enter__.return_value.get_users.return_value = {"relation-user1"} for dep_id in DEPARTED_IDS: for exception, expected_raise in PYMONGO_EXCEPTIONS: connection.return_value.__enter__.return_value.update_user.side_effect = exception with self.assertRaises(expected_raise): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._get_databases_from_relations") @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_no_auto_delete( self, connection, relation_users, databases_from_relations ): """Verifies when no-auto delete is specified databases are not dropped..""" # presets, such that the need to drop a database connection.return_value.__enter__.return_value.get_databases.return_value = {"db1", "db2"} databases_from_relations.return_value = {"d1"} self.harness.update_config({"auto-delete": False}) for dep_id in DEPARTED_IDS: self.harness.charm.client_relations.oversee_users(dep_id) connection.return_value.__enter__.return_value.drop_database.assert_not_called() @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_mongo_databases_failure(self, connection, relation_users): """Verifies failures in checking for databases with mongod result in raised exceptions.""" for dep_id in DEPARTED_IDS: for exception, expected_raise in PYMONGO_EXCEPTIONS: connection.return_value.__enter__.return_value.get_databases.side_effect = ( exception ) with self.assertRaises(expected_raise): self.harness.charm.client_relations.oversee_users(dep_id) @patch("charm.MongoDBProvider._get_databases_from_relations") @patch("charm.MongoDBProvider._get_users_from_relations") @patch("charms.mongodb_libs.v0.mongodb_provider.MongoDBConnection") def test_oversee_users_drop_database_failure( self, connection, relation_users, databases_from_relations ): """Verifies failures in dropping database result in raised exception.""" # presets, such that the need to drop a database connection.return_value.__enter__.return_value.get_databases.return_value = {"db1", "db2"} databases_from_relations.return_value = {"d1"} # verify operations across different inputs to oversee_users for dep_id in DEPARTED_IDS: for exception, expected_raise in PYMONGO_EXCEPTIONS: connection.return_value.__enter__.return_value.drop_database.side_effect = ( exception ) with self.assertRaises(expected_raise): # verify behaviour across relation event self.harness.charm.client_relations.oversee_users(dep_id)
51.218638
98
0.706088
1,686
14,290
5.682681
0.122183
0.061998
0.054796
0.046133
0.776119
0.756288
0.745747
0.719862
0.675295
0.670285
0
0.005578
0.209657
14,290
278
99
51.402878
0.842748
0.178027
0
0.676923
0
0
0.187871
0.137032
0
0
0
0
0.092308
1
0.076923
false
0
0.030769
0
0.112821
0
0
0
0
null
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
90be7d4a9a8d6b3d93746cb331cbc243b54edec8
164
py
Python
Escolas/Curso em Video/Back-End/Curso de Python/Mundos/Mundo 02/Aula_13.py
c4st1lh0/Projetos-de-Aula
e8abc9f4bce6cc8dbc6d7fb5da0f549ac8ef5302
[ "MIT" ]
null
null
null
Escolas/Curso em Video/Back-End/Curso de Python/Mundos/Mundo 02/Aula_13.py
c4st1lh0/Projetos-de-Aula
e8abc9f4bce6cc8dbc6d7fb5da0f549ac8ef5302
[ "MIT" ]
null
null
null
Escolas/Curso em Video/Back-End/Curso de Python/Mundos/Mundo 02/Aula_13.py
c4st1lh0/Projetos-de-Aula
e8abc9f4bce6cc8dbc6d7fb5da0f549ac8ef5302
[ "MIT" ]
null
null
null
for c in range(6, 0,-1): print(c) n1 = int(input('Inicio: ')) n2 = int(input('Fim: ')) n3 = int(input('Passo: ')) for c in range(n1, n2 + 1, n3): print(c)
18.222222
31
0.536585
31
164
2.83871
0.516129
0.272727
0.136364
0.25
0
0
0
0
0
0
0
0.078125
0.219512
164
9
32
18.222222
0.609375
0
0
0.285714
0
0
0.121212
0
0
0
0
0
0
1
0
false
0.142857
0
0
0
0.285714
0
0
0
null
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
4
90c9165b71e6a70a6b46e3dd1884adab9654da45
62
py
Python
lfs/shipping/__init__.py
michael-hahn/django-lfs
26c3471a8f8d88269c84f714f507b952dfdb6397
[ "BSD-3-Clause" ]
345
2015-01-03T19:19:27.000Z
2022-03-20T11:00:50.000Z
lfs/shipping/__init__.py
michael-hahn/django-lfs
26c3471a8f8d88269c84f714f507b952dfdb6397
[ "BSD-3-Clause" ]
73
2015-01-06T14:54:02.000Z
2022-03-11T23:11:34.000Z
lfs/shipping/__init__.py
michael-hahn/django-lfs
26c3471a8f8d88269c84f714f507b952dfdb6397
[ "BSD-3-Clause" ]
148
2015-01-07T16:30:08.000Z
2022-03-25T21:20:58.000Z
default_app_config = 'lfs.shipping.apps.LfsShippingAppConfig'
31
61
0.854839
7
62
7.285714
1
0
0
0
0
0
0
0
0
0
0
0
0.048387
62
1
62
62
0.864407
0
0
0
0
0
0.612903
0.612903
0
0
0
0
0
1
0
false
0
0
0
0
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
90d9e1d5c0f38ad9f2a375e31967377ff7bcc382
115
py
Python
vumi/transports/smpp/__init__.py
apopheniac/vumi
e04bf32a0cf09292f03dfe8628798adff512b709
[ "BSD-3-Clause" ]
null
null
null
vumi/transports/smpp/__init__.py
apopheniac/vumi
e04bf32a0cf09292f03dfe8628798adff512b709
[ "BSD-3-Clause" ]
null
null
null
vumi/transports/smpp/__init__.py
apopheniac/vumi
e04bf32a0cf09292f03dfe8628798adff512b709
[ "BSD-3-Clause" ]
2
2018-03-05T18:01:45.000Z
2019-11-02T19:34:18.000Z
""" SMPP transport API. """ from vumi.transports.smpp.transport import SmppTransport __all__ = ['SmppTransport']
14.375
56
0.747826
12
115
6.833333
0.75
0.317073
0
0
0
0
0
0
0
0
0
0
0.121739
115
7
57
16.428571
0.811881
0.165217
0
0
0
0
0.147727
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
90dc7b673450610f5c49a9ee2f0bf99f4edc6733
2,038
py
Python
test.py
sjyk/contradiction-dep
5d710b742669848fbc737f27674583d2d42279c7
[ "MIT" ]
null
null
null
test.py
sjyk/contradiction-dep
5d710b742669848fbc737f27674583d2d42279c7
[ "MIT" ]
null
null
null
test.py
sjyk/contradiction-dep
5d710b742669848fbc737f27674583d2d42279c7
[ "MIT" ]
null
null
null
import pandas as pd from cgd.dataflow import * from cgd.fact import * raw_data1 = [{'id': 1, 'title': 'Employee', 'branch':'SF' , 'salary': 60.0}, {'id': 2, 'title': 'Employee' , 'branch': 'SF', 'salary': 60.0}, {'id': 3, 'title': 'Employee', 'branch': 'NY' , 'salary': 100.0}, {'id': 4, 'title': 'Manager' , 'branch': 'SF','salary': 300.0}, {'id': 5, 'title': 'Manager', 'branch':'NY' ,'salary': 390.0}, {'id': 6, 'title': 'Manager', 'branch':'NY' ,'salary': 306.0}, {'id': 7, 'title': 'Sub' , 'branch': 'SF','salary': 10.0}, {'id': 8, 'title': 'Temp', 'branch': 'SF' ,'salary': 20.0}, {'id': 9, 'title': 'Manager', 'branch': 'NY' ,'salary': 400.0}] raw_data2 = [{'id': 1, 'title': 'Employee', 'branch':'SF' , 'salary': 100.0}, {'id': 2, 'title': 'Employee' , 'branch': 'SF', 'salary': 60.0}, {'id': 3, 'title': 'Employee', 'branch': 'NY' , 'salary': 100.0}, {'id': 4, 'title': 'Manager' , 'branch': 'SF','salary': 300.0}, {'id': 5, 'title': 'Manager', 'branch':'NY' ,'salary': 390.0}, {'id': 6, 'title': 'Manager', 'branch':'NY' ,'salary': 306.0}, {'id': 7, 'title': 'Sub' , 'branch': 'SF','salary': 10.0}, {'id': 8, 'title': 'Temp', 'branch': 'SF' ,'salary': 20.0}, {'id': 9, 'title': 'Manager', 'branch': 'NY' ,'salary': 400.0}] df1 = pd.DataFrame(raw_data1, columns=['id', 'title', 'branch', 'salary']) df2 = pd.DataFrame(raw_data2, columns=['id', 'title', 'branch', 'salary']) mdf = match(df1,df2, ['id']) #print(mdf) from cgd.constraint import * e = EmbeddedDependency(lambda x: x['title'] == 'Employee', lambda x: x['salary'] < 100) for i in e[df1]: print("a",i) for i in e[df2]: print("b",i) for i in e[mdf]: print("c",i) """ from cgd.constraint import * e = EmbeddedDependency(lambda x: x['title'] == 'Employee', lambda x: x['salary'] < 100, suffix='_right') for i in e[mdf]: print(i) """
39.960784
104
0.496565
270
2,038
3.72963
0.218519
0.047666
0.139027
0.119166
0.821251
0.760675
0.730884
0.698113
0.669315
0.669315
0
0.063259
0.23209
2,038
50
105
40.76
0.580192
0.004907
0
0.5
0
0
0.300809
0
0
0
0
0
0
1
0
false
0
0.125
0
0.125
0.09375
0
0
0
null
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
90f65346f624de35bc94adf3de5a571ddb53a368
257
py
Python
QRSMS/teacher_portal/serializers.py
Srishti-Ahuja/QRSMS-V1
1f2fa82e8ddaeb62e633fcd6a136696355317bba
[ "Apache-2.0" ]
4
2020-06-16T09:42:20.000Z
2021-11-24T08:18:16.000Z
QRSMS/teacher_portal/serializers.py
Srishti-Ahuja/QRSMS-V1
1f2fa82e8ddaeb62e633fcd6a136696355317bba
[ "Apache-2.0" ]
7
2021-04-08T21:57:34.000Z
2022-02-27T06:41:15.000Z
QRSMS/teacher_portal/serializers.py
Srishti-Ahuja/QRSMS-V1
1f2fa82e8ddaeb62e633fcd6a136696355317bba
[ "Apache-2.0" ]
7
2020-11-29T09:45:44.000Z
2022-03-30T15:27:33.000Z
from django.contrib.auth.models import Group from rest_framework import serializers from . import models class TeacherSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = models.Teacher fields = ['user', 'nu_email']
25.7
64
0.750973
28
257
6.821429
0.714286
0
0
0
0
0
0
0
0
0
0
0
0.175097
257
9
65
28.555556
0.900943
0
0
0
0
0
0.046693
0
0
0
0
0
0
1
0
false
0
0.428571
0
0.714286
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
292ad6969c31a89b8e32da9af92239a75e361c11
220
py
Python
minigest/tributi/serializers/tributo/inail.py
ctrlmaniac/minigest
2bfceb57e41c872e4112e24d0e6991164846888b
[ "MIT" ]
null
null
null
minigest/tributi/serializers/tributo/inail.py
ctrlmaniac/minigest
2bfceb57e41c872e4112e24d0e6991164846888b
[ "MIT" ]
1
2021-09-22T19:10:20.000Z
2021-09-22T19:10:20.000Z
minigest/tributi/serializers/tributo/inail.py
ctrlmaniac/minigest
2bfceb57e41c872e4112e24d0e6991164846888b
[ "MIT" ]
null
null
null
from rest_framework import serializers from ...models import TributoSezInail class TributoSezInailSerializer(serializers.ModelSerializer): class Meta: model = TributoSezInail exclude = ["imposta"]
22
61
0.75
19
220
8.631579
0.736842
0
0
0
0
0
0
0
0
0
0
0
0.186364
220
9
62
24.444444
0.916201
0
0
0
0
0
0.031818
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
292b3c36866be588d405443afa764d906533bd9f
50
py
Python
python/perspective/perspective/core/_version.py
welly87/perspective
34978877c246e76ad0a2db1d4fc93e1ef980f12f
[ "Apache-2.0" ]
null
null
null
python/perspective/perspective/core/_version.py
welly87/perspective
34978877c246e76ad0a2db1d4fc93e1ef980f12f
[ "Apache-2.0" ]
null
null
null
python/perspective/perspective/core/_version.py
welly87/perspective
34978877c246e76ad0a2db1d4fc93e1ef980f12f
[ "Apache-2.0" ]
null
null
null
__version__ = "1.3.1" major_minor_version = "1.3"
16.666667
27
0.7
9
50
3.222222
0.555556
0.551724
0.62069
0
0
0
0
0
0
0
0
0.113636
0.12
50
2
28
25
0.545455
0
0
0
0
0
0.16
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
2930cf2a2827e462cb1ecc874369996bdae20815
101
py
Python
example/celery_run.py
taogeT/flask-celery
b6dde08cbd034e22fa78e66fe76611de59a5dfe6
[ "BSD-2-Clause" ]
7
2016-03-27T16:55:38.000Z
2020-03-14T15:17:18.000Z
example/celery_run.py
taogeT/flask-celery
b6dde08cbd034e22fa78e66fe76611de59a5dfe6
[ "BSD-2-Clause" ]
null
null
null
example/celery_run.py
taogeT/flask-celery
b6dde08cbd034e22fa78e66fe76611de59a5dfe6
[ "BSD-2-Clause" ]
4
2016-04-13T10:02:51.000Z
2020-03-14T15:17:20.000Z
#!/usr/bin/env python # -*- coding: UTF-8 -*- from app import create_app, celery app = create_app()
16.833333
34
0.663366
16
101
4.0625
0.75
0.276923
0
0
0
0
0
0
0
0
0
0.011765
0.158416
101
5
35
20.2
0.752941
0.415842
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
29342764f0261c159474c537a5dae4645504460f
123
py
Python
orm2.0/app02/models.py
luyl1017713252/python
3b30cffa85b625e512415fa882b4bc7708a5e0b8
[ "MulanPSL-1.0" ]
null
null
null
orm2.0/app02/models.py
luyl1017713252/python
3b30cffa85b625e512415fa882b4bc7708a5e0b8
[ "MulanPSL-1.0" ]
null
null
null
orm2.0/app02/models.py
luyl1017713252/python
3b30cffa85b625e512415fa882b4bc7708a5e0b8
[ "MulanPSL-1.0" ]
null
null
null
from django.db import models # Create your models here. class Foo(models.Model): title=models.CharField(max_length=32)
24.6
41
0.772358
19
123
4.947368
0.842105
0
0
0
0
0
0
0
0
0
0
0.018692
0.130081
123
5
41
24.6
0.859813
0.195122
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.333333
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
293674c2f95365f3f6b980864bf787a479920cd5
124
py
Python
ssd/layers/functions/__init__.py
maddie157/BiDet
3cf7df65a50483e6bdd313d9d945c3dd6393e528
[ "MIT" ]
161
2020-03-08T10:37:00.000Z
2022-03-29T13:25:36.000Z
ssd/layers/functions/__init__.py
maddie157/BiDet
3cf7df65a50483e6bdd313d9d945c3dd6393e528
[ "MIT" ]
41
2020-03-10T10:13:06.000Z
2022-02-16T22:28:29.000Z
ssd/layers/functions/__init__.py
maddie157/BiDet
3cf7df65a50483e6bdd313d9d945c3dd6393e528
[ "MIT" ]
39
2020-03-15T22:33:38.000Z
2021-11-05T02:45:36.000Z
from .detection import Detect, DetectPrior from .prior_box import PriorBox __all__ = ['Detect', 'DetectPrior', 'PriorBox']
24.8
47
0.766129
14
124
6.428571
0.642857
0.377778
0
0
0
0
0
0
0
0
0
0
0.120968
124
4
48
31
0.825688
0
0
0
0
0
0.201613
0
0
0
0
0
0
1
0
false
0
0.666667
0
0.666667
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4