<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14670</bug_id>
          
          <creation_ts>2021-12-21 09:57:04 +0000</creation_ts>
          <short_desc>Promoting a Function to a Task: example is wrong</short_desc>
          <delta_ts>2025-04-11 08:39:23 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>BitBake User Manual</product>
          <component>bitbake-manual</component>
          <version>4.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>5.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Berger">pokylinux</reporter>
          <assigned_to name="Antonin Godard">antonin.godard</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>tim.orling</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>92200</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2021-12-21 09:57:04 +0000</bug_when>
    <thetext>https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#promoting-a-function-to-a-task

Bitbake does not like this python task - we should at least try to show valid examples ;)

python do_printdate () {
    import time
    print time.strftime(&apos;%Y%m%d&apos;, time.gmtime())
}
addtask printdate after do_fetch before do_build

Not sure what exactly we&apos;ll try to show here but maybe it is more like this:

    python do_printdate () {
-       import time
-       print time.strftime(&apos;%Y%m%d&apos;, time.gmtime())
+       import datetime
+       bb.plain(&apos;Date: %s&apos; % (datetime.date.today()))
    }
    addtask printdate after do_fetch before do_build

With bb.plain it shows up in the cooker shell and not just in some log file like with print. This would of course need additional explanations.

In case we would like to show even more maybe something like this, or a subset of it:

# this is a python task:
python do_printdate () {
    import datetime
    # goes to cooker shell:
    bb.warn(&apos;py: --&gt; S: %s &lt;--&apos; % (d.getVar(&quot;S&quot;, True)))
    bb.plain(&apos;py: Date: %s&apos; % (datetime.date.today()))
    # goes to log:
    print(datetime.datetime.now())
    print(datetime.date.today())
    # goes to cooker shell:
    bb.plain(&quot;py: Check the logs!&quot;)
    bb.plain(&apos;py: this log file: %s/log.do_printdate&apos; % (d.getVar(&quot;T&quot;, True)))
}
addtask do_printdate after do_compile before do_install

Please advise how the example should look like.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99998</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-10-24 15:03:56 +0000</bug_when>
    <thetext>Bulk move of 5.1 M4 to 5.2 M2 as approved by AlexB.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101627</commentid>
    <comment_count>2</comment_count>
    <who name="Antonin Godard">antonin.godard</who>
    <bug_when>2025-04-11 08:39:23 +0000</bug_when>
    <thetext>Fixed with commit https://git.openembedded.org/bitbake/commit/?id=874c607f475f3d60677d2720b80a28d0c2e963c6.

Moving to Resolved Fixed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>