imgurup Package¶
imgurup Package¶
-
class
imgurup.__init__.CLIImgur(url='api.imgur.com', client_id='55080e3fd8d0644', client_secret='d021464e1b3244d6f73749b94d17916cf361da24')¶ Bases:
imgurup.__init__.Imgur-
ask_album_id(albums)¶
-
ask_image_path()¶
-
ask_pin(auth_msg, auth_url, enter_token_msg)¶
-
get_ask_album_id_dialog_args(albums, no_album_msg)¶
-
get_ask_image_path_dialog_args()¶
-
get_auth_msg_dialog_args(auth_msg, auth_url)¶
-
get_enter_pin_dialog_args(token_msg)¶
-
get_error_dialog_args(msg='Error')¶
-
get_show_link_dialog_args(links)¶
-
show_link(image_link, delete_hash)¶
-
-
class
imgurup.__init__.Imgur(url='api.imgur.com', client_id='55080e3fd8d0644', client_secret='d021464e1b3244d6f73749b94d17916cf361da24')¶ Bases:
object-
CONFIG_PATH= '/home/docs/.imgurup.conf'¶
-
ask_album_id(albums)¶ Ask user to choose a album to upload or not belong to any album
Parameters: albums (list of dict) – Albums list Returns: The id of the album Return type: str
-
ask_image_path()¶ Display a file dialog and prompt the user to select a image
Returns: image path Return type: str
-
ask_pin(auth_msg, auth_url, enter_token_msg)¶ Ask user for pin code
Parameters: - auth_msg (str) – Authorization message
- auth_url (str) – Authorization url
- enter_token_msg (str) – Prompt token message
Returns: pin code
Return type: str
-
auth()¶ Authorization
-
get_ask_album_id_dialog_args(albums, no_album_msg)¶ Return the subprocess args of choose album dialog
Parameters: - albums (list of dict) – Albums list
- no_album_msg – Not belong to any album message
Returns: A list include dialog command
Return type: list
-
get_ask_image_path_dialog_args()¶ Return the subprocess args of file dialog
Returns: A list include dialog command, ex: [‘kdialog’, ‘–msgbox’, ‘hi’] Return type: list
-
get_auth_msg_dialog_args(auth_msg, auth_url)¶ Return the subprocess args of show authorization message dialog
Parameters: - auth_msg (str) – Authorization message
- auth_url (str) – Authorization url
Returns: A list include dialog command
Return type: list
-
get_enter_pin_dialog_args(token_msg)¶ Return the subprocess args of enter pin dialog
Parameters: token_msg (str) – Enter token message Returns: A list include dialog command Return type: list
-
get_error_dialog_args(msg='Error')¶ Return the subprocess args of display error dialog
Parameters: msg (str) – Error message Returns: A list include dialog command, ex: [‘kdialog’, ‘–msgbox’, ‘hello’] Return type: list
-
get_show_link_dialog_args(links)¶ Return the subprocess args of show link dialog
Parameters: links (str) – String of the image link and delete link Returns: A list include dialog command Return type: list
-
is_success(response)¶ Check the value of the result is success or not
Parameters: response (dict) – The result return from the server Returns: True if success, else False Return type: bool
-
request_album_list(*args, **kwargs)¶
-
request_new_tokens()¶ Request new tokens
Returns: json tokens Return type: dict
-
request_new_tokens_and_update()¶ Request and update the access token and refresh token
-
request_upload_image(*args, **kwargs)¶
-
retry(errors=(<class 'imgurup.__init__.ImgurError'>, <class 'httplib.BadStatusLine'>))¶ Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
-
set_tokens_using_config()¶ Read the token value from the config file Set tokens to None if can’t be found in config
-
show_error_and_exit(msg='Error')¶ Display error message and exit the program
Parameters: msg (str) – Error message
-
show_link(image_link, delete_hash)¶ Show image link
Parameters: - image_link (str) – Image link
- delete_hash (str) – Image delete hash string
-
upload(image_path=None, meta=None)¶ Upload a image
Parameters: - image_path (str) – The path of the image you want to upload
- meta (dict) – Meta information of anonymous and album id
Returns:
-
write_tokens_to_config()¶ Write token value to the config
-
-
exception
imgurup.__init__.ImgurError¶ Bases:
exceptions.Exception
-
class
imgurup.__init__.ImgurFactory¶ Used to produce imgur instance. You can call detect_env to auto get a suitable imgur class, and use it as argument in get_imgur. ex: imgur = ImgurFactory.get_imgur(ImgurFactory.detect_env(is_gui)) you can also manually choose a imgur class, ex: imgur = ImgurFactory.get_imgur(KDEImgur)
-
static
detect_env(is_gui=True)¶ Detect environment
Parameters: is_gui (bool) – If False, choose CLI, otherwise detect settings and choose a GUI mode Returns: Subclass of Imgur Return type: type
-
static
get_imgur(imgur_class)¶ Get imgur instance
Parameters: imgur_class (type) – The subclass name of Imgur Returns: Imgur instance
-
static
-
class
imgurup.__init__.KDEImgur(url='api.imgur.com', client_id='55080e3fd8d0644', client_secret='d021464e1b3244d6f73749b94d17916cf361da24')¶ Bases:
imgurup.__init__.Imgur-
get_ask_album_id_dialog_args(albums, no_album_msg)¶
-
get_ask_image_path_dialog_args()¶
-
get_auth_msg_dialog_args(auth_msg, auth_url)¶
-
get_enter_pin_dialog_args(token_msg)¶
-
get_error_dialog_args(msg='Error')¶
-
get_show_link_dialog_args(links)¶
-
-
class
imgurup.__init__.MacImgur(url='api.imgur.com', client_id='55080e3fd8d0644', client_secret='d021464e1b3244d6f73749b94d17916cf361da24')¶ Bases:
imgurup.__init__.Imgur-
ask_album_id(albums)¶
-
get_ask_album_id_dialog_args(albums, no_album_msg)¶
-
get_ask_image_path_dialog_args()¶
-
get_auth_msg_dialog_args(auth_msg, auth_url)¶
-
get_enter_pin_dialog_args(token_msg)¶
-
get_error_dialog_args(msg='Error')¶
-
get_show_link_dialog_args(links)¶
-
show_link(image_link, delete_hash)¶
-
-
class
imgurup.__init__.ZenityImgur(url='api.imgur.com', client_id='55080e3fd8d0644', client_secret='d021464e1b3244d6f73749b94d17916cf361da24')¶ Bases:
imgurup.__init__.Imgur-
get_ask_album_id_dialog_args(albums, no_album_msg)¶
-
get_ask_image_path_dialog_args()¶
-
get_auth_msg_dialog_args(auth_msg, auth_url)¶
-
get_enter_pin_dialog_args(token_msg)¶
-
get_error_dialog_args(msg='Error')¶
-
get_show_link_dialog_args(links)¶
-
-
imgurup.__init__.main()¶