def getSpecLines(self, spec): """ Get interpreted content of spec file """ stdout, stderr, rt = runCommand('rpmspec -P %s' % spec) if rt != 0: logging.error(stderr) return [] return stdout.split('\n')
def get(self, key): cmd = "etcdctl get \"%s\"" % key logging.info(cmd) so, se, rc = runCommand(cmd) if rc != 0: logging.info(se) return False, "" value = so.split("\n")[0] return True, value
def get(self, key): # key and values are string => escape quotes escaped_key = key.replace('"', '\\"') cmd = "etcdctl get \"%s\"" % escaped_key logging.info(cmd) so, se, rc = runCommand(cmd) if rc != 0: logging.info(se) return False, "" return True, so.split("\n")[0]
def set(self, key, value): # key and values are string => escape quotes escaped_key = key.replace('"', '\\"') escaped_value = value.replace('"', '\\"') # if the value is too long, save it into a file if len(escaped_value) > MAXIMUM_VALUE_LEN: f = tempfile.NamedTemporaryFile(delete=False) with open(f.name, 'w') as s: s.write(value) cmd = "etcdctl set \"%s\" < %s" % (escaped_key, f.name) so, se, rc = runCommand(cmd) if rc != 0: logging.info(se) return False f.close() else: cmd = "etcdctl set \"%s\" \"%s\"" % (escaped_key, escaped_value) so, se, rc = runCommand(cmd) if rc != 0: logging.info(se) return False return True