1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
diff -Naur --exclude='*.pyc' flickrfs-1.1/flickrapi.py flickrfs-1.1-mod/flickrapi.py
--- flickrfs-1.1/flickrapi.py 2005-11-08 15:21:57.000000000 +0100
+++ flickrfs-1.1-mod/flickrapi.py 2005-11-14 22:07:26.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!python
#
# Flickr API implementation
#
diff -Naur --exclude='*.pyc' flickrfs-1.1/flickrfs.conf flickrfs-1.1-mod/flickrfs.conf
--- flickrfs-1.1/flickrfs.conf 1970-01-01 01:00:00.000000000 +0100
+++ flickrfs-1.1-mod/flickrfs.conf 2005-11-14 21:03:03.000000000 +0100
@@ -0,0 +1,18 @@
+[USER]
+
+# for out-of-band auth inside a web browser
+browserName : /usr/bin/firefox
+
+
+#-------------------------------------------------------------------
+
+# It is not necessary to change these. They just identifies this as
+# this application as flickrfs so that flickr.com can track the
+# usage by different api's
+
+# API key
+flickrAPIKey : f8aa9917a9ae5e44a87cae657924f42d
+
+# shared "secret"
+flickrSecret : 3fbf7144be7eca28
+
diff -Naur --exclude='*.pyc' flickrfs-1.1/flickrfs.py flickrfs-1.1-mod/flickrfs.py
--- flickrfs-1.1/flickrfs.py 2005-11-08 22:01:39.000000000 +0100
+++ flickrfs-1.1-mod/flickrfs.py 2005-11-14 21:56:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python
#@+leo-ver=4
#@+node:@file flickrfs.py
# v0.9 - Initial release
@@ -48,11 +48,22 @@
#Import flickr python api
from flickrapi import FlickrAPI
-# flickr auth information
-flickrAPIKey = "f8aa9917a9ae5e44a87cae657924f42d" # API key
-flickrSecret = "3fbf7144be7eca28" # shared "secret"
-browserName = "/usr/bin/firefox" # for out-of-band auth inside a web browser
+# Import ConfigParser
+from ConfigParser import ConfigParser
+def read_config(config_file = '/etc/flickrfs/flickrfs.conf'):
+ defaults = {
+ 'flickrAPIKey' : "f8aa9917a9ae5e44a87cae657924f42d", # API key
+ 'flickrSecret' : "3fbf7144be7eca28", # shared "secret"
+ 'browserName' : "/usr/bin/firefox",} # for out-of-band auth inside a web browser
+
+ config = ConfigParser(defaults)
+ config.add_section('USER')
+
+ if os.access(config_file, os.R_OK):
+ config.read(config_file)
+
+ return config
class TransFlickr: #Transactions with flickr
def uploadfile(self, filepath, taglist, bufData, mode):
@@ -246,26 +257,28 @@
running in foreground, you can have threads
"""
log.info("sets_thread: started")
- self._mkfileOrDir("/sets", isDir=True)
+ self._mkfileOrDir("/sets", isDir=True)
rsp = fapi.photosets_getList(api_key=flickrAPIKey, auth_token=token)
if rsp!=None:
- for a in rsp.photosets[0].photoset:
- title = a.title[0].elementText.replace('/', ' ')
- curdir = "/sets/" + title
- if title.strip()=='':
- curdir = "/sets/" + a['id']
- set_id = a['id']
- self._mkfileOrDir(curdir, id=set_id, isDir=True)
- photos = fapi.photosets_getPhotos(api_key=flickrAPIKey, photoset_id=set_id)
- if photos!=None:
- for b in photos.photoset[0].photo:
- title = b['title'].replace('/', ' ')
- if title.strip()=='':
- title = str(b['id'])
- title = title[:32] #Only allow 32 characters
- self._mkfileOrDir(curdir+'/'+title, \
- id=str(b['id']), isDir=False)
-
+ try:
+ for a in rsp.photosets[0].photoset:
+ title = a.title[0].elementText.replace('/', ' ')
+ curdir = "/sets/" + title
+ if title.strip()=='':
+ curdir = "/sets/" + a['id']
+ set_id = a['id']
+ self._mkfileOrDir(curdir, id=set_id, isDir=True)
+ photos = fapi.photosets_getPhotos(api_key=flickrAPIKey, photoset_id=set_id)
+ if photos!=None:
+ for b in photos.photoset[0].photo:
+ title = b['title'].replace('/', ' ')
+ if title.strip()=='':
+ title = str(b['id'])
+ title = title[:32] #Only allow 32 characters
+ self._mkfileOrDir(curdir+'/'+title, \
+ id=str(b['id']), isDir=False)
+ except Exception, e:
+ print str(e)
@@ -700,6 +713,12 @@
#@+node:mainline
if __name__ == '__main__':
+
+ config = read_config()
+ flickrAPIKey = config.get('USER', 'flickrAPIKey')
+ flickrSecret = config.get('USER', 'flickrSecret')
+ browserName = config.get('USER', 'browserName')
+
try:
server = Flickrfs()
server.multithreaded = 1;
diff -Naur --exclude='*.pyc' flickrfs-1.1/setup.py flickrfs-1.1-mod/setup.py
--- flickrfs-1.1/setup.py 1970-01-01 01:00:00.000000000 +0100
+++ flickrfs-1.1-mod/setup.py 2005-11-14 20:23:31.000000000 +0100
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import sys
+
+from distutils.core import setup
+
+# this affects the names of all the directories we do stuff with
+sys.path.insert(0, './')
+
+setup(name = 'flickrfs',
+ version = 1.1,
+ description = 'A virtual filesystem that provides easy access to flickr',
+ author = 'Manish Rai Jain',
+ author_email = 'manishrjain@gmail.com',
+ url = 'http://flickrfs.sourceforge.net/',
+ py_modules = ['flickrapi'],
+ scripts = ['flickrfs'],
+ data_files = [('/etc/flickrfs', ['flickrfs.conf'])],
+ license = 'GPL',
+ )
|