def main(argv = None): """ main entry point """ configfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "perscon", "perscon.conf") config.parse(configfile) service = "google.com" username = config.user(service) password = keyring.get_password(service, username) gd_client = gdata.photos.service.PhotosService() gd_client.email = username gd_client.password = password gd_client.source = 'py-perscon-v01' gd_client.ProgrammaticLogin() uri = "http://localhost:5985/" Perscon_utils.init_url(uri) ##### # Get pictures from Picasa ##### albums = gd_client.GetUserFeed(user=username) # iterate over albums for album in albums.entry: print 'title: %s, number of photos: %s, id: %s' % (album.title.text, album.numphotos.text, album.gphoto_id.text) album_id = album.gphoto_id.text # iterate over pictures photos = gd_client.GetFeed('/data/feed/api/user/%s/albumid/%s?kind=photo' % (username, album_id)) for photo in photos.entry: print 'Photo title:', photo.title.text image_url = photo.content.src uid = photo.gphoto_id.text mime,mime_enc = mimetypes.guess_type(photo.content.src) if not mime: mime = 'application/octet-stream' fin = urllib2.urlopen(image_url) data = fin.read() fin.close() Perscon_utils.rpc('att/'+uid, headers={'Content-type':mime,'Content-length':len(data)}, data=data) tstamp = photo.timestamp.text m = {'origin':'com.google.picasa', 'mtime':tstamp, 'att': [uid], 'uid': uid, 'tags':[] } meta={}
def main(argv = None): """ main entry point """ configfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "perscon", "perscon.conf") config.parse(configfile) service = "google.com" username = config.user(service) password = keyring.get_password(service, username) gd_client = gdata.docs.service.DocsService(source='py-perscon-v01') gd_client.ClientLogin(username, password) uri = "http://localhost:5985/" Perscon_utils.init_url (uri) feed = gd_client.GetDocumentListFeed() if not feed.entry: print 'No items found.\n' for entry in feed.entry: parseObject(entry, gd_client)
def handle_export(self, req: HTTPRequest, res: HTTPResponse): self.db.userdata.save() res.serve_file(config.user("fanch"), forceDownload=True)
x.pagesize = args["nperpage"] if "nperpage" in args else 20 self.requests[x.id] = tmp res.serve_file_gen(path, x.moustache(self.userlist_object())) def handle_create_request(self, req: HTTPRequest, res: HTTPResponse): self.db.userdata.add_request(req.params["name"], req.body_json()) self.db.userdata.save() def handle_delete_request(self, req: HTTPRequest, res: HTTPResponse): self.db.userdata.delete_request(req.params["name"]) self.db.userdata.save() filecache.init() usr = None if os.path.exists(config.user("fanch")): usr = user.User.fromjsonfile("fanch") else: usr = user.User.createuser("fanch") browser = None port = 8080 logfile = sys.stdout if len(sys.argv) > 2: i = 1 while i < len(sys.argv): arg = sys.argv[i] if arg == "-b" or arg == "--browser": browser = sys.argv[i + 1] i += 1 if arg == "-p" or arg == "--port":
# This Python program is based on features added in Python 3.5. Python 3.7 is recommanded. # Requires Pillow >= 6.0.0 for ImageOps.exif_transpose() in utils.py from PIL import Image import math from os import walk, listdir from os.path import isfile, join import config from image import is_animated, rotate, combineImages from video import animate, getFps, avgFps # Load configuration args = config.args() userconf = config.user(args.config) CONFIG = config.general(args, userconf) CANVAS_ATT = config.canvas(args, userconf) FFMPEG = config.ffmpeg(args, userconf) # Walk in subdirectories (jour 1, jour 2, ...) for root, dirs, _ in walk(CONFIG["ROOT_DIR"]): print("dirs in root: " + str(dirs)) # Debug # For each subdir for subdir in dirs: dir = join(root, subdir) print("current subdir: " + str(dir)) # Debug # Read all the files in the dir & keep only images images = [] for file in listdir(dir): file = join(dir, file) try:
def fromjsonfile(file): file = config.user(file) with open(file) as f: usr = User(js=json.loads(f.read())) return usr
def save(self): userpath = config.user(self.name) with open(userpath, "w") as f: f.write(self.json()) self.change = False