input
stringlengths
11
5.29k
target
stringlengths
20
8.26k
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def update_relations(self, records=None, contributed_values=None, **kwarg): self.records_obj = [] records = [] if not records else records for rec_dict in records: rec = DatasetEntryORM(dataset_id=int(self.id), **rec_dict) self.records_obj.append(rec) self.contributed_values_obj = [] contributed_values = {} if not contributed_values else contributed_values for key, rec_dict in contributed_values.items(): rec = ContributedValuesORM(collection_id=int(self.id), **rec_dict) self.contributed_values_obj.append(rec)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _contributed_values(contributed_values_obj): return DatasetORM._contributed_values(contributed_values_obj)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def current_additions(): """ Proxy to the currently added requirements """ rv = _additional_ctx_stack.top if rv is None: return None return rv[1]
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def from_json(cls, inp): """Create an analemma from a dictionary.""" return cls(inp['sun_vectors'], inp['sun_up_hours'])
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def sun_vectors(self): """Return list of sun vectors.""" return self._sun_vectors
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def to_json(self): """Convert analemma to a dictionary.""" return {'sun_vectors': self.sun_vectors, 'sun_up_hours': self.sun_up_hours}
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def to_rows(self, message): record_batch = self._parse_arrow_message(message) # Iterate through each column simultaneously, and make a dict from the # row values for row in zip(*record_batch.columns): yield dict(zip(self._column_names, row))
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_coeffs(page): """Parse coefficients from the page.""" coeffs = {} coeffs['datetime'] = [] coeffs['slope1'] = [] coeffs['intercept1'] = [] coeffs['slope2'] = [] coeffs['intercept2'] = [] slope1_idx, intercept1_idx, slope2_idx, intercept2_idx = \ None, None, None, None date_idx = 0 for row in page.lower().split('\n'): row = row.split() if len(row) == 0: continue if row[0] == 'update': # Get the column indices from the header line slope1_idx = row.index('slope_lo') intercept1_idx = row.index('int_lo') slope2_idx = row.index('slope_hi') intercept2_idx = row.index('int_hi') continue if slope1_idx is None: continue # In some cases the fields are connected, skip those rows if max([slope1_idx, intercept1_idx, slope2_idx, intercept2_idx]) >= len(row): continue try: dat = dt.datetime.strptime(row[date_idx], "%m/%d/%Y") except ValueError: continue coeffs['datetime'].append([dat.year, dat.month, dat.day]) coeffs['slope1'].append(float(row[slope1_idx])) coeffs['intercept1'].append(float(row[intercept1_idx])) coeffs['slope2'].append(float(row[slope2_idx])) coeffs['intercept2'].append(float(row[intercept2_idx])) return coeffs
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def aligned_array(shape, align, dtype, order='C'): d = dtype(0) N = np.prod(shape) tmp = np.zeros(N * d.nbytes + align, dtype=np.uint8) address = tmp.__array_interface__["data"][0] for offset in range(align): if (address + offset) % align == 0: break tmp = tmp[offset:offset+N*d.nbytes].view(dtype=dtype) return tmp.reshape(shape, order=order)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def as_aligned(arr, align, dtype, order='C'): aligned = aligned_array(arr.shape, align, dtype, order) aligned[:] = arr[:] return aligned
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def __new__(cls, *args, **kwargs): return np.array(*args, **kwargs).view(cls)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def setUp(self): self.x = 2*np.ones((3,), dtype=int) self.y = 3*np.ones((3,), dtype=int) self.x2 = 2*np.ones((2, 3), dtype=int) self.y2 = 3*np.ones((2, 3), dtype=int) self.ind = [0, 0, 1]
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def mtype(s): n, offset, fields = 0, 0, [] for c in s.split(','): # subarrays won't work if c != '-': fields.append(('f{0}'.format(n), c, offset)) n += 1 offset += np.dtype(c).itemsize if c != '-' else psize names, formats, offsets = zip(*fields) return np.dtype({'names': names, 'formats': formats, 'offsets': offsets, 'itemsize': offset})
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def collect(frame): global frames frames.append(frame)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def __init__(self, capacity): self.examplers = deque(maxlen=capacity) self.capacity = capacity
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_random_samples(self, num_samples): num_samples = min(num_samples, len(self.examplers)) return random.sample(tuple(self.examplers), num_samples)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_random_stacks(self, num_samples, stack_size): start_indices = random.sample(range(len(self.examplers)), num_samples) return [self.get_stack(start_index, stack_size) for start_index in start_indices]
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def on_remove_duplicates_state_changed(self): self.fuzz_table_model.remove_duplicates = self.ui.chkBRemoveDuplicates.isChecked() self.fuzz_table_model.update() self.remove_duplicates()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def __add_fuzzing_range(self): start = self.ui.sBAddRangeStart.value() end = self.ui.sBAddRangeEnd.value() step = self.ui.sBAddRangeStep.value() self.fuzz_table_model.add_range(start, end + 1, step)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def index(self, request): queryset = Condition.objects.select_related('source', 'target_option') serializer = ConditionIndexSerializer(queryset, many=True) return Response(serializer.data)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def define_tables(cls, metadata): Table( "table1", metadata, Column( "id", Integer, primary_key=True, test_needs_autoincrement=True ), Column("data", String(30)), ) Table( "table2", metadata, Column( "id", Integer, primary_key=True, test_needs_autoincrement=True ), Column("someid", None, ForeignKey("table1.id")), )
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_basic(self): table2, table1 = self.tables.table2, self.tables.table1 Session = scoped_session(sa.orm.sessionmaker(testing.db)) class CustomQuery(query.Query): pass class SomeObject(fixtures.ComparableEntity): query = Session.query_property() class SomeOtherObject(fixtures.ComparableEntity): query = Session.query_property() custom_query = Session.query_property(query_cls=CustomQuery) self.mapper_registry.map_imperatively( SomeObject, table1, properties={"options": relationship(SomeOtherObject)}, ) self.mapper_registry.map_imperatively(SomeOtherObject, table2) s = SomeObject(id=1, data="hello") sso = SomeOtherObject() s.options.append(sso) Session.add(s) Session.commit() Session.refresh(sso) Session.remove() eq_( SomeObject( id=1, data="hello", options=[SomeOtherObject(someid=1)] ), Session.query(SomeObject).one(), ) eq_( SomeObject( id=1, data="hello", options=[SomeOtherObject(someid=1)] ), SomeObject.query.one(), ) eq_( SomeOtherObject(someid=1), SomeOtherObject.query.filter( SomeOtherObject.someid == sso.someid ).one(), ) assert isinstance(SomeOtherObject.query, query.Query) assert not isinstance(SomeOtherObject.query, CustomQuery) assert isinstance(SomeOtherObject.custom_query, query.Query)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_bind(self, mapper=None, **kwargs): return super().get_bind(mapper=mapper, **kwargs)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_bind(self, mapper=None, *args, **kwargs): return super().get_bind(mapper, *args, **kwargs)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_bind(self, mapper=None, *args, **kwargs): return super(MySession, self).get_bind( mapper, *args, **kwargs )
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_bind(self, mapper=None, **kwargs): return super(MySession, self).get_bind( mapper=mapper, **kwargs )
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _get_unique_constraints(self, table): """Retrieve information about existing unique constraints of the table This feature is needed for _recreate_table() to work properly. Unfortunately, it's not available in sqlalchemy 0.7.x/0.8.x. """ data = table.metadata.bind.execute( """SELECT sql FROM sqlite_master WHERE type='table' AND name=:table_name""", table_name=table.name ).fetchone()[0] UNIQUE_PATTERN = "CONSTRAINT (\w+) UNIQUE \(([^\)]+)\)" return [ UniqueConstraint( *[getattr(table.columns, c.strip(' "')) for c in cols.split(",")], name=name ) for name, cols in re.findall(UNIQUE_PATTERN, data) ]
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _recreate_table(self, table, column=None, delta=None, omit_uniques=None): """Recreate the table properly Unlike the corresponding original method of sqlalchemy-migrate this one doesn't drop existing unique constraints when creating a new one. """ table_name = self.preparer.format_table(table) # we remove all indexes so as not to have # problems during copy and re-create for index in table.indexes: index.drop() # reflect existing unique constraints for uc in self._get_unique_constraints(table): table.append_constraint(uc) # omit given unique constraints when creating a new table if required table.constraints = set([ cons for cons in table.constraints if omit_uniques is None or cons.name not in omit_uniques ]) self.append('ALTER TABLE %s RENAME TO migration_tmp' % table_name) self.execute() insertion_string = self._modify_table(table, column, delta) table.create(bind=self.connection) self.append(insertion_string % {'table_name': table_name}) self.execute() self.append('DROP TABLE migration_tmp') self.execute()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _visit_migrate_unique_constraint(self, *p, **k): """Drop the given unique constraint The corresponding original method of sqlalchemy-migrate just raises NotImplemented error """ self.recreate_table(p[0].table, omit_uniques=[p[0].name])
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def patch_migrate(): """A workaround for SQLite's inability to alter things SQLite abilities to alter tables are very limited (please read http://www.sqlite.org/lang_altertable.html for more details). E. g. one can't drop a column or a constraint in SQLite. The workaround for this is to recreate the original table omitting the corresponding constraint (or column). sqlalchemy-migrate library has recreate_table() method that implements this workaround, but it does it wrong: - information about unique constraints of a table is not retrieved. So if you have a table with one unique constraint and a migration adding another one you will end up with a table that has only the latter unique constraint, and the former will be lost - dropping of unique constraints is not supported at all The proper way to fix this is to provide a pull-request to sqlalchemy-migrate, but the project seems to be dead. So we can go on with monkey-patching of the lib at least for now. """ # this patch is needed to ensure that recreate_table() doesn't drop # existing unique constraints of the table when creating a new one helper_cls = sqlite.SQLiteHelper helper_cls.recreate_table = _recreate_table helper_cls._get_unique_constraints = _get_unique_constraints # this patch is needed to be able to drop existing unique constraints constraint_cls = sqlite.SQLiteConstraintDropper constraint_cls.visit_migrate_unique_constraint = \ _visit_migrate_unique_constraint constraint_cls.__bases__ = (ansisql.ANSIColumnDropper, sqlite.SQLiteConstraintGenerator)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _db_schema_sanity_check(engine): """Ensure all database tables were created with required parameters. :param engine: SQLAlchemy engine instance for a given database """ if engine.name == 'mysql': onlyutf8_sql = ('SELECT TABLE_NAME,TABLE_COLLATION ' 'from information_schema.TABLES ' 'where TABLE_SCHEMA=%s and ' 'TABLE_COLLATION NOT LIKE "%%utf8%%"') table_names = [res[0] for res in engine.execute(onlyutf8_sql, engine.url.database)] if len(table_names) > 0: raise ValueError(_('Tables "%s" have non utf8 collation, ' 'please make sure all tables are CHARSET=utf8' ) % ','.join(table_names))
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def callproc(self, procname, params=None): result = self._no_monkey.callproc(self, procname, params) if transaction_states[self.db.alias]: transaction_states[self.db.alias].mark_dirty() return result
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def execute(self, sql, params=None): result = self._no_monkey.execute(self, sql, params) if transaction_states[self.db.alias] and is_sql_dirty(sql): transaction_states[self.db.alias].mark_dirty() return result
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def executemany(self, sql, param_list): result = self._no_monkey.executemany(self, sql, param_list) if transaction_states[self.db.alias] and is_sql_dirty(sql): transaction_states[self.db.alias].mark_dirty() return result
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def is_sql_dirty(sql): # This should not happen as using bytes in Python 3 is against db protocol, # but some people will pass it anyway if isinstance(sql, bytes): sql = sql.decode() # NOTE: not using regex here for speed sql = sql.lower() for action in ('update', 'insert', 'delete'): p = sql.find(action) if p == -1: continue start, end = p - 1, p + len(action) if (start < 0 or sql[start] not in CHARS) and (end >= len(sql) or sql[end] not in CHARS): return True else: return False
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _convert_objectGUID(item): item = uuid.UUID("{{{0!s}}}".format(item)).bytes_le item = escape_bytes(item) return item
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def __exit__(self, exc_type, exc_val, exc_tb): connection = connections[get_tenant_database_alias()] connection.set_tenant(self._previous_tenant.pop())
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def activate(self): """ Syntax sugar that helps at django shell with fast tenant changing Usage: Tenant.objects.get(schema_name='test').activate() """ connection = connections[get_tenant_database_alias()] connection.set_tenant(self)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def deactivate(cls): """ Syntax sugar, return to public schema Usage: test_tenant.deactivate() # or simpler Tenant.deactivate() """ connection = connections[get_tenant_database_alias()] connection.set_schema_to_public()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def save(self, verbosity=1, *args, **kwargs): connection = connections[get_tenant_database_alias()] is_new = self.pk is None has_schema = hasattr(connection, 'schema_name') if has_schema and is_new and connection.schema_name != get_public_schema_name(): raise Exception("Can't create tenant outside the public schema. " "Current schema is %s." % connection.schema_name) elif has_schema and not is_new and connection.schema_name not in (self.schema_name, get_public_schema_name()): raise Exception("Can't update tenant outside it's own schema or " "the public schema. Current schema is %s." % connection.schema_name) super().save(*args, **kwargs) if has_schema and is_new and self.auto_create_schema: try: self.create_schema(check_if_exists=True, verbosity=verbosity) post_schema_sync.send(sender=TenantMixin, tenant=self.serializable_fields()) except Exception: # We failed creating the tenant, delete what we created and # re-raise the exception self.delete(force_drop=True) raise elif is_new: # although we are not using the schema functions directly, the signal might be registered by a listener schema_needs_to_be_sync.send(sender=TenantMixin, tenant=self.serializable_fields()) elif not is_new and self.auto_create_schema and not schema_exists(self.schema_name): # Create schemas for existing models, deleting only the schema on failure try: self.create_schema(check_if_exists=True, verbosity=verbosity) post_schema_sync.send(sender=TenantMixin, tenant=self.serializable_fields()) except Exception: # We failed creating the schema, delete what we created and # re-raise the exception self._drop_schema() raise
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def create_schema(self, check_if_exists=False, sync_schema=True, verbosity=1): """ Creates the schema 'schema_name' for this tenant. Optionally checks if the schema already exists before creating it. Returns true if the schema was created, false otherwise. """ # safety check connection = connections[get_tenant_database_alias()] _check_schema_name(self.schema_name) cursor = connection.cursor() if check_if_exists and schema_exists(self.schema_name): return False fake_migrations = get_creation_fakes_migrations() if sync_schema: if fake_migrations: # copy tables and data from provided model schema base_schema = get_tenant_base_schema() clone_schema = CloneSchema() clone_schema.clone_schema(base_schema, self.schema_name) call_command('migrate_schemas', tenant=True, fake=True, schema_name=self.schema_name, interactive=False, verbosity=verbosity) else: # create the schema cursor.execute('CREATE SCHEMA "%s"' % self.schema_name) call_command('migrate_schemas', tenant=True, schema_name=self.schema_name, interactive=False, verbosity=verbosity) connection.set_schema_to_public()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def save(self, *args, **kwargs): # Get all other primary domains with the same tenant domain_list = self.__class__.objects.filter(tenant=self.tenant, is_primary=True).exclude(pk=self.pk) # If we have no primary domain yet, set as primary domain by default self.is_primary = self.is_primary or (not domain_list.exists()) if self.is_primary: # Remove primary status of existing domains for tenant domain_list.update(is_primary=False) super().save(*args, **kwargs)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_metrics(self): """Returns the stored metrics. The metrics are type checked against the set schema. Returns: Dictionary of metrics data in the format of the set schema. """ artifact_utils.verify_schema_instance(self._schema, self._values) return self._values
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _init_liststore(self): """Creates the liststore""" self.liststore = Gtk.ListStore(object, GdkPixbuf.Pixbuf, str, str) self.set_model(self.liststore)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def validate_unique(self): '''This clean method will check for unique_together condition''' # Collect unique_checks and to run from all the forms. all_unique_checks = set() all_date_checks = set() forms_to_delete = self.deleted_forms valid_forms = [form for form in self.forms if form.is_valid() and form not in forms_to_delete] for form in valid_forms: unique_checks, date_checks = form.instance._get_unique_checks() all_unique_checks.update(unique_checks) all_date_checks.update(date_checks) errors = [] # Do each of the unique checks (unique and unique_together) for uclass, unique_check in all_unique_checks: seen_data = set() for form in valid_forms: # Get the data for the set of fields that must be unique among the forms. row_data = ( field if field in self.unique_fields else form.cleaned_data[field] for field in unique_check if field in form.cleaned_data ) # Reduce Model instances to their primary key values row_data = tuple(d._get_pk_val() if hasattr(d, '_get_pk_val') else d for d in row_data) if row_data and None not in row_data: # if we've already seen it then we have a uniqueness failure if row_data in seen_data: # poke error messages into the right places and mark # the form as invalid errors.append(self.get_unique_error_message(unique_check)) form._errors[NON_FIELD_ERRORS] = self.error_class([self.get_form_error()]) # remove the data from the cleaned_data dict since it was invalid for field in unique_check: if field in form.cleaned_data: del form.cleaned_data[field] # mark the data as seen seen_data.add(row_data) if errors: raise ValidationError(errors)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def append_for(module, suffix): # Modules have to be appended to the existing mysql.pp # otherwise pp will fail for some of them saying that # Mysql::Config definition is missing. template = "mysql_%s_%s.pp" % (module, suffix) manifestdata.append(getManifestTemplate(template))
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): # execute with a non-unicode object. a warning is emitted, # this warning shouldn't clog up memory. testing.db.execute(table1.select().where(table1.c.col2 == 'foo%d' % i[0])) i[0] += 1
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): m1 = mapper(A, table1, properties={ "bs":relationship(B, order_by=table2.c.col1) }) m2 = mapper(B, table2) m3 = mapper(A, table1, non_primary=True) sess = create_session() a1 = A(col2="a1") a2 = A(col2="a2") a3 = A(col2="a3") a1.bs.append(B(col2="b1")) a1.bs.append(B(col2="b2")) a3.bs.append(B(col2="b3")) for x in [a1,a2,a3]: sess.add(x) sess.flush() sess.expunge_all() alist = sess.query(A).order_by(A.col1).all() eq_( [ A(col2="a1", bs=[B(col2="b1"), B(col2="b2")]), A(col2="a2", bs=[]), A(col2="a3", bs=[B(col2="b3")]) ], alist) for a in alist: sess.delete(a) sess.flush() sess.close() clear_mappers()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): class A(fixtures.ComparableEntity): pass class B(A): pass mapper(A, table1, polymorphic_on=table1.c.col2, polymorphic_identity='a') mapper(B, table2, inherits=A, polymorphic_identity='b') sess = create_session() a1 = A() a2 = A() b1 = B(col3='b1') b2 = B(col3='b2') for x in [a1,a2,b1, b2]: sess.add(x) sess.flush() sess.expunge_all() alist = sess.query(A).order_by(A.col1).all() eq_( [ A(), A(), B(col3='b1'), B(col3='b2') ], alist) for a in alist: sess.delete(a) sess.flush() # dont need to clear_mappers() del B del A
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): class A(fixtures.ComparableEntity): pass class B(fixtures.ComparableEntity): pass mapper(A, table1, properties={ 'bs':relationship(B, secondary=table3, backref='as', order_by=table3.c.t1) }) mapper(B, table2) sess = create_session() a1 = A(col2='a1') a2 = A(col2='a2') b1 = B(col2='b1') b2 = B(col2='b2') a1.bs.append(b1) a2.bs.append(b2) for x in [a1,a2]: sess.add(x) sess.flush() sess.expunge_all() alist = sess.query(A).order_by(A.col1).all() eq_( [ A(bs=[B(col2='b1')]), A(bs=[B(col2='b2')]) ], alist) for a in alist: sess.delete(a) sess.flush() # dont need to clear_mappers() del B del A
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): r = e.execute(t.alias().select()) for row in r: row[t.c.x]
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): s = table2.select() sess = session() sess.query(Foo).join((s, Foo.bars)).all() sess.rollback()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def go(): dialect = SQLiteDialect() cast.compile(dialect=dialect)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def records(self): """calculated property when accessed, not saved in the DB A view of the many to many relation""" return self._records(self.records_obj)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def forwards(self, orm): # Adding unique constraint on 'Vendeur', fields ['code_permanent'] db.create_unique(u'encefal_vendeur', ['code_permanent'])
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def to_arrow(self, read_session=None): """Create a :class:`pyarrow.Table` of all rows in the stream. This method requires the pyarrow library and a stream using the Arrow format. Args: read_session ( \ ~google.cloud.bigquery_storage_v1.types.ReadSession \ ): DEPRECATED. This argument was used to specify the schema of the rows in the stream, but now the first message in a read stream contains this information. Returns: pyarrow.Table: A table of all rows in the stream. """ return self.rows(read_session=read_session).to_arrow()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test___doc__(self): self.assertEqual( ctds.Parameter.__doc__, '''\
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def getAllTrips(uid): #trips = list(get_trip_db().find({"user_id":uid, "type":"move"})) query = {'user_id':uid, 'type':'move'} return get_trip_db().find(query)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def getTrainingTrips(uid): return getTrainingTrips_Date(uid, 30) query = {'user_id':uid, 'type':'move'} return get_trip_db().find(query)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def getAlternativeTrips(trip_id): #TODO: clean up datetime, and queries here #d = datetime.datetime.now() - datetime.timedelta(days=6) #query = {'trip_id':trip_id, 'trip_start_datetime':{"$gt":d}} query = {'trip_id':trip_id} alternatives = get_alternatives_db().find(query) if alternatives.estimated_document_count() > 0: logging.debug("Number of alternatives for trip %s is %d" % (trip_id, alternatives.estimated_document_count())) return alternatives raise AlternativesNotFound("No Alternatives Found")
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def create(db): # Create simple queue table. Using TEXT unless there is a reason not to. db.execute("CREATE TABLE IF NOT EXISTS queue (value BLOB)")
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def pop(db): limit = 2 # <- Not empirically/theoretically tested db.execute("SELECT value FROM queue ORDER BY rowid LIMIT (?)", (limit,)) value = db.fetchall() # a list of (value, ) tuples, or None if value: # pop values (i.e. delete rows with len(value) lowest row ids) db.execute("DELETE FROM queue WHERE rowid in (SELECT rowid FROM queue ORDER BY rowid LIMIT (?))", (len(value),)) return value
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _format_transaction_id(cls, transaction_id): return ('_' + transaction_id)[:32] # such formation is required by server.
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def db_type(self, connection): return 'list'
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_prep_lookup(self, lookup_type, value): if hasattr(value, 'prepare'): return value.prepare() if hasattr(value, '_prepare'): return value._prepare() if value is None: raise ValueError("You can't query an iterable field with None") if lookup_type == 'isnull' and value in (True, False): return value if lookup_type != 'exact' and lookup_type != 'in': raise ValueError("You can only query using exact and in lookups on iterable fields") if isinstance(value, (list, set)): return [ self.item_field_type.to_python(x) for x in value ] return self.item_field_type.to_python(value)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def pre_save(self, model_instance, add): """ Gets our value from the model_instance and passes its items through item_field's pre_save (using a fake model instance). """ value = getattr(model_instance, self.attname) if value is None: return None return self._map(lambda item: self.item_field_type.pre_save(_FakeModel(self.item_field_type, item), add), value)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) if value is None: return None # If the value is an empty iterable, store None if value == self._iterable_type([]): return None return self._map(self.item_field_type.get_db_prep_save, value, connection=connection)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False): """ Passes the value through get_db_prep_lookup of item_field. """ return self.item_field_type.get_db_prep_lookup( lookup_type, value, connection=connection, prepared=prepared)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def db_type(self, connection): return 'set'
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_db_prep_lookup(self, *args, **kwargs): ret = super(SetField, self).get_db_prep_lookup(*args, **kwargs) if ret: ret = list(ret) return ret
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _insert_data(self, t, index): """Add a single row with value 'index' to the given tablet.""" t.mquery( 'vt_test_keyspace', "insert into vt_insert_test (msg) values ('test %s')" % index, write=True)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def on_doctype_update(): frappe.db.add_index("ToDo", ["reference_type", "reference_name"])
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_initialize(self): self.tdb.initialize() self.assertIsNone(self.tdb.mypref_db) self.assertIsNone(self.tdb.votecast_db) self.assertIsNone(self.tdb.channelcast_db)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def load_apartment(apartment_id): # type: (int) -> Optional[ApartmentDTO] apartment_orm = Apartment.select().where(Apartment.id == apartment_id).first() if apartment_orm is None: return None apartment_dto = ApartmentMapper.orm_to_dto(apartment_orm) return apartment_dto
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def load_apartment_by_mailbox_id(mailbox_id): # type: (int) -> Optional[ApartmentDTO] apartment_orm = Apartment.select().where(Apartment.mailbox_rebus_id == mailbox_id).first() if apartment_orm is None: return None apartment_dto = ApartmentMapper.orm_to_dto(apartment_orm) return apartment_dto
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def load_apartments(): # type: () -> List[ApartmentDTO] apartments = [] for apartment_orm in Apartment.select(): apartment_dto = ApartmentMapper.orm_to_dto(apartment_orm) apartments.append(apartment_dto) return apartments
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def get_apartment_count(): # type: () -> int return Apartment.select().count()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def db_key_pair_create_duplicate(context): raise exception.KeyPairExists(key_name='create_duplicate')
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def create_database(self, name, owner=None): """Create a new database :param name: database name :type name: basestring :param owner: username of the owner or None if unspecified :type owner: basestring """ with psycopg2.connect(database='postgres', user=DatabaseRunner.ADMIN_USER, host='localhost', port=self.running_port) as conn: conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) with conn.cursor() as cursor: sql = 'CREATE DATABASE {name} ' + ('WITH OWNER {owner}' if owner else '') cursor.execute(sql.format(name=name, owner=owner))
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def _db_key_pair_get(context, user_id, name): raise exception.KeypairNotFound(user_id=user_id, name=name)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def set_context(self, context): # Context to keep for database access if self.network_builder: self.network_builder.set_context(context)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def db(base_app): """Initialize database.""" # Init if not database_exists(str(_db.engine.url)): create_database(str(_db.engine.url)) _db.create_all() yield _db # Teardown _db.session.remove() _db.drop_all()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def app(base_app, es, db): """Application with ES and DB.""" yield base_app
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def ExecuteSql(self, request, context): """Executes an SQL statement, returning all results in a single reply. This
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def ExecuteStreamingSql(self, request, context): """Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def ExecuteBatchDml(self, request, context): """Executes a batch of SQL DML statements. This method allows many statements
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def Read(self, request, context): """Reads rows from the database using key lookups and scans, as a
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def __init__(self, bika_listing = None, table_only = False): BikaListingTable.__init__(self, bika_listing, True) self.rows_headers = [] self.trans_items = {} self.positions = [] self._transpose_data()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def applies(cls, obj): if not cls.loaded(): return False import cudf return isinstance(obj, (cudf.DataFrame, cudf.Series))
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def init(cls, eltype, data, kdims, vdims): import cudf import pandas as pd element_params = eltype.param.objects() kdim_param = element_params['kdims'] vdim_param = element_params['vdims'] if isinstance(data, (cudf.Series, pd.Series)): data = data.to_frame() if not isinstance(data, cudf.DataFrame): data, _, _ = PandasInterface.init(eltype, data, kdims, vdims) data = cudf.from_pandas(data) columns = list(data.columns) ncols = len(columns) index_names = [data.index.name] if index_names == [None]: index_names = ['index'] if eltype._auto_indexable_1d and ncols == 1 and kdims is None: kdims = list(index_names) if isinstance(kdim_param.bounds[1], int): ndim = min([kdim_param.bounds[1], len(kdim_param.default)]) else: ndim = None nvdim = vdim_param.bounds[1] if isinstance(vdim_param.bounds[1], int) else None if kdims and vdims is None: vdims = [c for c in columns if c not in kdims] elif vdims and kdims is None: kdims = [c for c in columns if c not in vdims][:ndim] elif kdims is None: kdims = list(columns[:ndim]) if vdims is None: vdims = [d for d in columns[ndim:((ndim+nvdim) if nvdim else None)] if d not in kdims] elif kdims == [] and vdims is None: vdims = list(columns[:nvdim if nvdim else None]) # Handle reset of index if kdims reference index by name for kd in kdims: kd = dimension_name(kd) if kd in columns: continue if any(kd == ('index' if name is None else name) for name in index_names): data = data.reset_index() break if any(isinstance(d, (np.int64, int)) for d in kdims+vdims): raise DataError("cudf DataFrame column names used as dimensions " "must be strings not integers.", cls) if kdims: kdim = dimension_name(kdims[0]) if eltype._auto_indexable_1d and ncols == 1 and kdim not in columns: data = data.copy() data.insert(0, kdim, np.arange(len(data))) for d in kdims+vdims: d = dimension_name(d) if len([c for c in columns if c == d]) > 1: raise DataError('Dimensions may not reference duplicated DataFrame ' 'columns (found duplicate %r columns). If you want to plot ' 'a column against itself simply declare two dimensions ' 'with the same name. '% d, cls) return data, {'kdims':kdims, 'vdims':vdims}, {}
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def select(cls, dataset, selection_mask=None, **selection): df = dataset.data if selection_mask is None: selection_mask = cls.select_mask(dataset, selection) indexed = cls.indexed(dataset, selection) if selection_mask is not None: df = df.loc[selection_mask] if indexed and len(df) == 1 and len(dataset.vdims) == 1: return df[dataset.vdims[0].name].iloc[0] return df
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def concat_fn(cls, dataframes, **kwargs): import cudf return cudf.concat(dataframes, **kwargs)
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def aggregate(cls, dataset, dimensions, function, **kwargs): data = dataset.data cols = [d.name for d in dataset.kdims if d in dimensions] vdims = dataset.dimensions('value', label='name') reindexed = data[cols+vdims] agg = function.__name__ if len(dimensions): agg_map = {'amin': 'min', 'amax': 'max'} agg = agg_map.get(agg, agg) grouped = reindexed.groupby(cols, sort=False) if not hasattr(grouped, agg): raise ValueError('%s aggregation is not supported on cudf DataFrame.' % agg) df = getattr(grouped, agg)().reset_index() else: agg_map = {'amin': 'min', 'amax': 'max', 'size': 'count'} agg = agg_map.get(agg, agg) if not hasattr(reindexed, agg): raise ValueError('%s aggregation is not supported on cudf DataFrame.' % agg) agg = getattr(reindexed, agg)() data = dict(((col, [v]) for col, v in zip(agg.index.values_host, agg.to_array()))) df = util.pd.DataFrame(data, columns=list(agg.index.values_host)) dropped = [] for vd in vdims: if vd not in df.columns: dropped.append(vd) return df, dropped
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def dframe(cls, dataset, dimensions): if dimensions: return dataset.data[dimensions].to_pandas() else: return dataset.data.to_pandas()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_impl(df): df2 = df[['A']] df2['A'] += 10 return df2.A, df.A
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_impl(n): S1 = pd.Series(np.ones(n)) S2 = pd.Series(np.random.ranf(n)) df = pd.DataFrame({'A': S1, 'B': S2}) return df.A.sum()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_impl(df): return df['A'][df['B']].values
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_impl(): A = np.array([1., 2., 3.]) A[0] = np.nan df = pd.DataFrame({'A': A}) B = df.A.fillna(5.0) return B.sum()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_impl(): A = np.array([1., 2., 3.]) A[0] = np.nan df = pd.DataFrame({'A': A}) df.A.fillna(5.0, inplace=True) return df.A.sum()
def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
def test_impl(): A = np.array([1., 2., 3.]) A[0] = np.nan df = pd.DataFrame({'A': A}) return df.A.mean()