def _upload_or_replace_fb(self,directory,fn,_album_id,_megapixels=None,resize_request=None,movealbum_request=None,changetitle_request=None,_title=None):
<EOL>db=self._loadDB(directory)<EOL>if _megapixels:<EOL><INDENT>fp = tempfile.NamedTemporaryFile()<EOL>fullfile_resized=fp.name<EOL>logger.debug("<STR_LIT>"%(fp.name))<EOL><DEDENT>fullfile=os.path.join(directory,fn)<EOL>ext=os.path.splitext(fullfile)[<NUM_LIT:1>].lower()<EOL>if ext=='<STR_LIT>':<EOL><INDENT>isJPG=True<EOL><DEDENT>else:<EOL><INDENT>isJPG=False<EOL><DEDENT>if fn in db:<EOL><INDENT>pid=db[fn]['<STR_LIT>']<EOL>if resize_request and isJPG:<EOL><INDENT>logger.info("<STR_LIT>",fn)<EOL>if self._already_resized_on_fb(fullfile,pid,_megapixels):<EOL><INDENT>logger.debug("<STR_LIT>",fn)<EOL>return True<EOL><DEDENT><DEDENT>elif movealbum_request:<EOL><INDENT>logger.info("<STR_LIT>",fn)<EOL>if self._already_in_album(fullfile,pid,_album_id):<EOL><INDENT>logger.debug("<STR_LIT>",fn)<EOL>return True<EOL><DEDENT><DEDENT>elif changetitle_request:<EOL><INDENT>logger.info("<STR_LIT>",fn)<EOL>if self._title_uptodate(fullfile,pid,_title):<EOL><INDENT>logger.debug("<STR_LIT>",fn)<EOL>return True<EOL><DEDENT><DEDENT>logger.debug("<STR_LIT>",fn)<EOL>if not self._remove_media(directory,fn):<EOL><INDENT>logger.error("<STR_LIT>",fn)<EOL>return False<EOL><DEDENT><DEDENT>if _megapixels and isJPG:<EOL><INDENT>if pusher_utils.resize_image(fullfile,fullfile_resized,_megapixels):<EOL><INDENT>logger.debug("<STR_LIT>"%(fullfile,fullfile_resized))<EOL>fullfile=fullfile_resized<EOL><DEDENT>else:<EOL><INDENT>logger.warning("<STR_LIT>"%(fullfile))<EOL><DEDENT><DEDENT>logger.debug("<STR_LIT>",fn,_album_id,_title)<EOL>resp=self.fb.put_photo(open(fullfile),message=_title,album_id=_album_id,)<EOL>logger.debug("<STR_LIT>"%(fn,resp))<EOL>if '<STR_LIT:id>' not in resp:<EOL><INDENT>print(("<STR_LIT>", fn))<EOL>return False<EOL><DEDENT>pid=resp['<STR_LIT:id>']<EOL>db[fn]={}<EOL>db[fn]['<STR_LIT>']=pid<EOL>logger.debug("<STR_LIT>",fn,pid);<EOL>self._saveDB(directory,db)<EOL>return True<EOL>
Does the actual upload to fb.
        if resize_request, will resize picture only if
        it already exists and the geometry on fb doesn't match
        what we want,
        returns (status)