genouest / biomaj

BioMAJ
http://genouest.github.io/biomaj/
GNU Affero General Public License v3.0
12 stars 10 forks source link

Wrong month number value parsed from ftp date #28

Closed horkko closed 8 years ago

horkko commented 8 years ago

Hi

For ftp protocol at leste there is a problem when getting the date of a file. A file with date 10/06/2015 for exemple leads to a release of 2015-6-10. I think it should be 2015-06-10.

Thanks

osallou commented 8 years ago

modification is easy, but would impact existing banks. Release would be seen as a different release and force an update. We could keep this as default and propose an option in config to format the release with a regexp like: %d-%M-%Y etc... (using Python syntax for date format)

horkko commented 8 years ago

Hi, Yes that sounds a good idea to me.

horkko commented 8 years ago

@osallou referring #28

Hi,

After testing it, the commit https://github.com/genouest/biomaj/commit/8320ab25115009fbe26d1d0776a85d04edc9b0b7 does not solve the problem. At least it works for python 2.x but not for python3. To be valid, release.format must escape datetime format like %%d-%%m-%%Y instead of %d-%m-%Y as mentioned above.

In python 3 with release.format=%d-%m-%Y, an error is raised :

2016-03-21 13:30:15,093 ERROR [root][MainThread] Workflow:preprocessException:'%' must be followed by '%' or '(', found: '%d-%m-%Y'

but it works for python 2. Updating the value to release.format=%%d-%%m-%%Y works ok for python 3, however, python 2 does not complain, but the value stored in database is wrong:

    {
      "freeze": false,
      "remoterelease": "%d-%m-%Y",
      "session": 1458563868.408677,
      "data_dir": "/home/tuco/src/workspace/BIOMAJ_CONFIGS/banks",
      "formats": [
        "fasta"
      ],
      "release": "%d-%m-%Y__4",
      "dir_version": "dbtestA",
      "prod_dir": "dbtestA-%d-%m-%Y__4",
      "types": [
        "nucleic",
        "protein"
      ],
      "size": 96101239
    }

Do you think it could be easily solved? Thanks

Emmanuel

osallou commented 8 years ago

I will have a look, this one of issues to support multiple py versions. Maybe a simple test on python version?

Le lun. 21 mars 2016 13:40, Emmanuel Quevillon notifications@github.com a écrit :

@osallou https://github.com/osallou referring #28 https://github.com/genouest/biomaj/issues/28

Hi,

After testing it, the commit 8320ab2 https://github.com/genouest/biomaj/commit/8320ab25115009fbe26d1d0776a85d04edc9b0b7 does not solve the problem. At least it works for python 2.x but not for python3. To be valid, release.format must escape datetime format like %%d-%%m-%%Y instead of %d-%m-%Y as mentioned above.

In python 3 with release.format=%d-%m-%Y, an error is raised :

2016-03-21 13:30:15,093 ERROR [root][MainThread] Workflow:preprocessException:'%' must be followed by '%' or '(', found: '%d-%m-%Y'

but it works for python 2. Updating the value to release.format=%%d-%%m-%%Y works ok for python 3, however, python 2 does not complain, but the value stored in database is wrong:

{
  "freeze": false,
  "remoterelease": "%d-%m-%Y",
  "session": 1458563868.408677,
  "data_dir": "/home/tuco/src/workspace/BIOMAJ_CONFIGS/banks",
  "formats": [
    "fasta"
  ],
  "release": "%d-%m-%Y__4",
  "dir_version": "dbtestA",
  "prod_dir": "dbtestA-%d-%m-%Y__4",
  "types": [
    "nucleic",
    "protein"
  ],
  "size": 96101239
}

Do you think it could be easily solved? Thanks

Emmanuel

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/genouest/biomaj/issues/28#issuecomment-199254925

horkko commented 8 years ago

40