[
https://issues.apache.org/jira/browse/AMBARI-13271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15005240#comment-15005240
]
Masahiro TANAKA commented on AMBARI-13271:
------------------------------------------
Your suggestion sounds good to me, but your don't fix this problem properly.
filePath is already a string type, so you don't need type conversion.
I think `"%s" % e` changes type implicitly, but for code consistency, you
should write the patch as below:
logger.warn('Could not backup file "%s": %s' % (filePath, str(e)))
Also, your patch's name doesn't follow the rule. From
https://cwiki.apache.org/confluence/display/AMBARI/How+to+Contribute ,
you should name the patch "AMABRI-13271.path" or something ?
> Error: str() function only 1 takes parameter
> --------------------------------------------
>
> Key: AMBARI-13271
> URL: https://issues.apache.org/jira/browse/AMBARI-13271
> Project: Ambari
> Issue Type: Bug
> Components: ambari-agent
> Affects Versions: 2.1.1
> Environment: CentOS 7.0
> Reporter: Kevin Vasko
> Priority: Minor
> Attachments: patch.diff
>
>
> In the file
> /usr/lib/python2.6/site-packages/ambari_agent/HostCleanup.py
> and in the backup_file function I was getting an error staying Error: str()
> only takes 1 parameter but 2 were passed type error.
> # Copy file and save with file.# (timestamp)
> def backup_file(filePath):
> if filePath is not None and os.path.exists(filePath):
> timestamp = datetime.datetime.now()
> format = '%Y%m%d%H%M%S'
> try:
> shutil.copyfile(filePath, filePath + "." + timestamp.strftime(format))
> except (Exception), e:
> logger.warn('Could not backup file "%s": %s' % (str(filePath, e)))
> return 0
> I do believe the exception handling line is incorrect and should be change
> from:
> logger.warn('Could not backup file "%s": %s' % (str(filePath, e)))
> to:
> logger.warn('Could not backup file "%s": %s' % (str(filePath), e))
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)