Lines 22-30
Link Here
|
22 |
import os |
22 |
import os |
23 |
import time |
23 |
import time |
24 |
|
24 |
|
25 |
# flickr auth information |
25 |
# Import ConfigParser |
26 |
flickrAPIKey = "f8aa9917a9ae5e44a87cae657924f42d" # API key |
26 |
from ConfigParser import ConfigParser |
27 |
flickrSecret = "3fbf7144be7eca28" # shared "secret" |
27 |
|
|
|
28 |
def read_config(config_file = '/etc/flickrfs/flickrfs.conf'): |
29 |
defaults = { |
30 |
'flickrAPIKey' : "f8aa9917a9ae5e44a87cae657924f42d", # API key |
31 |
'flickrSecret' : "3fbf7144be7eca28", # shared "secret" |
32 |
'browserName' : "/usr/bin/firefox",} # for out-of-band auth inside a web browser |
33 |
|
34 |
config = ConfigParser(defaults) |
35 |
config.add_section('USER') |
36 |
|
37 |
if os.access(config_file, os.R_OK): |
38 |
config.read(config_file) |
39 |
|
40 |
return config |
28 |
|
41 |
|
29 |
# Utility functions |
42 |
# Utility functions |
30 |
def kwdict(**kw): return kw |
43 |
def kwdict(**kw): return kw |
Lines 38-44
Link Here
|
38 |
def __init__(self, logg, browserName): |
51 |
def __init__(self, logg, browserName): |
39 |
global log |
52 |
global log |
40 |
log = logg |
53 |
log = logg |
41 |
self.fapi = FlickrAPI(flickrAPIKey, flickrSecret) |
54 |
|
|
|
55 |
config = read_config() |
56 |
self.flickrAPIKey = config.get('USER', 'flickrAPIKey') |
57 |
self.flickrSecret = config.get('USER', 'flickrSecret') |
58 |
self.browserName = config.get('USER', 'browserName') |
59 |
|
60 |
self.fapi = FlickrAPI(self.flickrAPIKey, self.flickrSecret) |
42 |
self.user_id = "" |
61 |
self.user_id = "" |
43 |
# proceed with auth |
62 |
# proceed with auth |
44 |
# TODO use auth.checkToken function if available, |
63 |
# TODO use auth.checkToken function if available, |
Lines 302-308
Link Here
|
302 |
return (bw['max'], bw['used']) |
321 |
return (bw['max'], bw['used']) |
303 |
|
322 |
|
304 |
def getUserId(self): |
323 |
def getUserId(self): |
305 |
rsp = self.fapi.auth_checkToken(api_key=flickrAPIKey, |
324 |
rsp = self.fapi.auth_checkToken(api_key=self.flickrAPIKey, |
306 |
auth_token=self.authtoken) |
325 |
auth_token=self.authtoken) |
307 |
if not rsp: |
326 |
if not rsp: |
308 |
log.error("Unable to get userid:" + rsp.errormsg) |
327 |
log.error("Unable to get userid:" + rsp.errormsg) |