aequitas / concourse-ftp-resource

Concourse resource to interact with FTP servers.
https://hub.docker.com/r/aequitas/ftp-resource/
MIT License
3 stars 6 forks source link

custom resource type 'ftp' version not found #6

Closed SaurabhQA closed 6 years ago

SaurabhQA commented 6 years ago

I am getting the resource script related error while using the ftp resource type.

yml file contents are as below Below is the content of the pipeline. resource_types:

resources:

Below is the error seen in the concourse UI.

resource script '/opt/resource/check []' failed: exit status 1

stderr: DEBUG:root:command: check DEBUG:root:input: {'version': None, 'source': {'regex': '(?Pfilename(?P[0-9\_]+)-\.bin)', 'uri': 'ftp://username:pass@server:21/path/', 'debug': True}} DEBUG:root:args: [] INFO:root:connecting to ftp server INFO:root:logging in INFO:root:changing to directory /path/ Traceback (most recent call last): File "/opt/resource/check", line 226, in print(FTPResource().run(os.path.basename(file), sys.stdin.read(), sys.argv[1:])) File "/opt/resource/check", line 72, in run output = self.cmd_check(version=data.get('version', {})) File "/opt/resource/check", line 123, in cmd_check versions = self._versions_to_output(self._matching_versions(self.listdir())) File "/opt/resource/check", line 117, in listdir return [self.parser.parse_line(d)._st_name for d in dirlist] File "/opt/resource/check", line 117, in return [self.parser.parse_line(d)._st_name for d in dirlist] File "/usr/local/lib/python3.5/site-packages/ftputil/stat.py", line 399, in parse_line year_or_time, name = self._split_line(line) File "/usr/local/lib/python3.5/site-packages/ftputil/stat.py", line 372, in _split_line format(line)) ftputil.error.ParserError: line 'total 905328' can't be parsed Debugging info: ftputil 3.3.1, Python 3.5.1 (linux)

aequitas commented 6 years ago

I think this is due to an unexpected response from the FTP server. Can you share a dir list response from the server?

SaurabhQA commented 6 years ago

Thanks for the reply. Below is the dir list from the server

curl ftp://username:password@server:21/path/ total 905328 -r-xr-xr-x 1 current ird 463509504 Dec 21 11:54 filename9_5_1_0-linux64.bin -rw-r--r-- 1 current ird 64 Dec 21 11:54 filename9_5_1_0-linux64.bin.SHA-256

aequitas commented 6 years ago

This change should fix your issue: https://github.com/aequitas/concourse-ftp-resource/commit/a058fc0b4d27581e02158ebe6c588cbd839eefad

A new docker image should be build automatically in a few minutes, please reopen this issue if you still have the problem.

SaurabhQA commented 6 years ago

Now I am getting the below error. I see a similar issue raised earlier related to SemVer version. I am planning to change the test_check.py. Hope that is the correct approach to solve the below error.

stderr: DEBUG:root:command: check DEBUG:root:input: {'source': {'debug': True, 'regex': '(?Psetup-IP-(?P[0-9\_]+)-linux64\.bin)', 'uri': 'ftp://qaqtp:QA-qtp09@frack.lss.emc.com:21/work/distr/CDROMS/test-versions/IP-9.5.1.0/LATEST/linux_64/IP_NETWORK_SUITE/suite/'}, 'version': None} DEBUG:root:args: [] INFO:root:connecting to ftp server INFO:root:logging in INFO:root:changing to directory /work/distr/CDROMS/test-versions/IP-9.5.1.0/LATEST/linux_64/IP_NETWORK_SUITE/suite/ Traceback (most recent call last): File "/opt/resource/check", line 227, in print(FTPResource().run(os.path.basename(file), sys.stdin.read(), sys.argv[1:])) File "/opt/resource/check", line 73, in run output = self.cmd_check(version=data.get('version', {})) File "/opt/resource/check", line 124, in cmd_check versions = self._versions_to_output(self._matching_versions(self.listdir())) File "/opt/resource/check", line 202, in _versions_to_output versions.sort(key=lambda x: semver.parse_version_info(x[self.version_key])) File "/opt/resource/check", line 202, in versions.sort(key=lambda x: semver.parse_version_info(x[self.version_key])) File "/usr/local/lib/python3.6/site-packages/semver.py", line 123, in parse_version_info parts = parse(version) File "/usr/local/lib/python3.6/site-packages/semver.py", line 50, in parse raise ValueError('%s is not valid SemVer string' % version) ValueError: 9_5_1_0 is not valid SemVer string

aequitas commented 6 years ago

Next time could you please put output like this inside a codeblock so it's easier to read?

test_check.py is only to verify functionality of the code, you would have to modify ftp.py as well to actual make a change to the behaviour. Any PR with a good test is welcome.