def export(self): if not os.path.isdir(self.directory): os.makedirs(self.directory) if not self.verbose: output_idx = self.outputMgr.create_output_obj("Converting " + self.book.title, len(self.book.images)) for index in range(0, len(self.book.images)): directory = os.path.join(unicode(self.directory), unicode(self.book.title)) source = unicode(self.book.images[index]) new_source = os.path.join(self.book.images[index] + "." + imghdr.what(str(source))) target = os.path.join(directory, '%05d.png' % index) if self.verbose: print(str(index) + " Target = " + target) if index == 0: try: if not os.path.isdir(directory): os.makedirs(directory) except OSError: return try: base = os.path.join(directory, unicode(self.book.title)) manga_name = base + '.manga' if self.verbose: print(manga_name) if self.book.overwrite or not os.path.isfile(manga_name): manga = open(manga_name, 'w') manga.write('\x00') manga.close() manga_save_name = base + '.manga_save' if self.book.overwrite or not os.path.isfile(manga_save_name): manga_save = open(base + '.manga_save', 'w') save_data = u'LAST=/mnt/us/pictures/%s/%s' % (self.book.title, os.path.split(target)[1]) if self.verbose: print("SaveData = " + save_data) manga_save.write(save_data.encode('utf-8')) manga_save.close() except IOError: return False os.renames(source, new_source) try: if self.book.overwrite or not os.path.isfile(target): image.convert_image(new_source, target, str(self.book.device), self.book.imageFlags) if self.verbose: print(source + " -> " + target) else: self.outputMgr.update_output_obj(output_idx) except RuntimeError: print("ERROR") finally: os.renames(new_source, source)
def handleTweet(imgurl, name, tweetid, api, startX, startY, satPlaceSocket): print("startX: ", startX) print("startY: ", startY) filename = wget.download(imgurl, out=config.uploaded_image_folder) cj = convert_image(filename, (config.image_size, config.image_size), startX, startY) emitResult = satPlaceSocket.emitNewOrder(cj) if emitResult: satPlaceSocket.wait(seconds=5) try: invoice = satPlaceSocket.receivedInvoice print(invoice) api.update_status("@" + name + " " + invoice['paymentRequest'], tweetid) except AttributeError: print("Failed to get invoice") api.update_status("Sorry @" + name + ", try again please!", tweetid) else: api.update_status("Sorry @" + name + ", try again please!", tweetid)
# ------------------------------------------------------------------------------------------------------------- # Copyright 2013 Oleksiy Voronin # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software distributed under the License # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and limitations under the License # ------------------------------------------------------------------------------------------------------------- import image import params if __name__ == '__main__': params.prepare_parser('%prog [options] image_file') (options, args) = params.retrieve_options() if len(args) == 0: params.print_usage() else: print image.convert_image(args[0], options.mode)
print("Running Satoshis.Place Image Uploader...") url='https://api.satoshis.place' height = int(input("Enter image height in pixels: ")) width = int(input("Enter image width in pixels: ")) imgx = int(input("Enter canvas coordinate x: ")) imgy = int(input("Enter canvas coordinate y: ")) satPlaceSocket = SatPlaceSocket() print("Connecting to API") filename = "img.png" print("Converting Image") cj = convert_image(filename, (height, width), imgx, imgy) print("Requesting Invoice") emitResult = satPlaceSocket.emitNewOrder(cj) if emitResult: satPlaceSocket.wait(seconds=5) try: invoice = satPlaceSocket.receivedInvoice print("Invoice received: ") print(invoice) invoiceexists = True except AttributeError: print("Failed to get invoice") else: print("- - -") if invoiceexists == True: