def sync_file_to_s3(self, file, base): "Sync a single file to S3" filepath = re.sub(base, '', file.name) try: #filepath = filepath.encode('utf-8', 'replace') filepath = filepath except: print "Error: " + filepath return key = self.bucket.get_key_metadata(filepath) # The file exists, let's see if it needs to be updated if key and file.size == key['size'] and file.mtime == key['mtime']: # Nothing has changed, no need to update this file if self.configuration.verbose > 1: print file.name + " ... Skipping" return key = self.bucket.get_key(filepath, True) key.size = file.size key.mtime = file.mtime if file.link: key.link = str(file.link) if self.configuration.verbose: #print file.name.encode('ascii', 'replace') print file.name self.bucket.add(key, file) file.close()
def build_json(action, cmd, str): file = open('/home/iosdev747/Desktop/Linus/Linus/output.txt', 'w') data = {} order = [] Image = [] URI = [] Text = [] if not str == "": order.append(3) Text.append(Text.append({"data": str})) data['title'] = action data['order'] = order data['Image'] = Image data['URI'] = URI data['Text'] = Text data['command'] = cmd json_data = json.dumps(data) file.write(json_data) file.close()
def main(): username, password = Login() session = getCookies(username, password) if session == 0: password = rePasswd() session = getCookies(username, password) if session == 0: username, password = Login() session = getCookies(username, password) if session == 0: password = rePasswd() session = getCookies(username, password) if session == 0: print 'Sorry GoodBye~' sys.exit(0) content, who = PageOne(session) # Save file to index.html file = open('index.html', 'w') file.write(content) file.close()
def write_data(m, t, path, dot, dir, f, a): path_save = r'' with open(os.path.join(path_save, 'checked_files.txt'), 'a+') as file: file.write(f'{path};{dir};{f};{a};{dot};{m};{t}\n') file.close()