{"action":"closed","issue":{"url":"https://api.github.com/repos/Jumpscale/jumpscale_core7/issues/38","labels_url":"https://api.github.com/repos/Jumpscale/jumpscale_core7/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/Jumpscale/jumpscale_core7/issues/38/comments","events_url":"https://api.github.com/repos/Jumpscale/jumpscale_core7/issues/38/events","html_url":"https://github.com/Jumpscale/jumpscale_core7/issues/38","id":89213617,"number":38,"title":"SAL nginx, impossible to use with empty or non existing config","user":{"login":"zaibon","id":303164,"avatar_url":"https://avatars.githubusercontent.com/u/303164?v=3","gravatar_id":"","url":"https://api.github.com/users/zaibon","html_url":"https://github.com/zaibon","followers_url":"https://api.github.com/users/zaibon/followers","following_url":"https://api.github.com/users/zaibon/following{/other_user}","gists_url":"https://api.github.com/users/zaibon/gists{/gist_id}","starred_url":"https://api.github.com/users/zaibon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaibon/subscriptions","organizations_url":"https://api.github.com/users/zaibon/orgs","repos_url":"https://api.github.com/users/zaibon/repos","events_url":"https://api.github.com/users/zaibon/events{/privacy}","received_events_url":"https://api.github.com/users/zaibon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"muhamadazmy","id":10920323,"avatar_url":"https://avatars.githubusercontent.com/u/10920323?v=3","gravatar_id":"","url":"https://api.github.com/users/muhamadazmy","html_url":"https://github.com/muhamadazmy","followers_url":"https://api.github.com/users/muhamadazmy/followers","following_url":"https://api.github.com/users/muhamadazmy/following{/other_user}","gists_url":"https://api.github.com/users/muhamadazmy/gists{/gist_id}","starred_url":"https://api.github.com/users/muhamadazmy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muhamadazmy/subscriptions","organizations_url":"https://api.github.com/users/muhamadazmy/orgs","repos_url":"https://api.github.com/users/muhamadazmy/repos","events_url":"https://api.github.com/users/muhamadazmy/events{/privacy}","received_events_url":"https://api.github.com/users/muhamadazmy/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-06-18T06:41:20Z","updated_at":"2015-07-05T06:46:37Z","closed_at":"2015-07-05T06:46:37Z","body":"Would be great of if could be possible to create a config from scratch. \r\nCurrently I can't use this SAL on a file that doesn't exist yet or is empty.\r\n ```\r\nnginx.config\r\n[localhost:22] run: test -e /path/doesnt/exists && echo OK ; true\r\n---------------------------------------------------------------------------\r\nAssertionError                            Traceback (most recent call last)\r\n/usr/local/bin/js in <module>()\r\n----> 1 nginx.config\r\n\r\n/opt/jumpscale7/lib/JumpScale/lib/ssh/nginx/manager.pyc in config(self)\r\n     31     def config(self):\r\n     32         if self._config is None:\r\n---> 33             content = self._con.file_read(self._path)\r\n     34             self._config = NginxConfig(content)\r\n     35         return self._config\r\n\r\n/opt/jumpscale7/lib/cuisine.pyc in wrapper(*args, **kwargs)\r\n    139                 def wrapper(*args, **kwargs):\r\n    140                         log_call(function, args, kwargs)\r\n--> 141                         return function(*args, **kwargs)\r\n    142                 # We copy name and docstring\r\n    143                 functools.update_wrapper(wrapper, function)\r\n\r\n/opt/jumpscale7/lib/cuisine.pyc in file_read(location, default)\r\n    561         # NOTE: We use base64 here to be sure to preserve the encoding (UNIX/DOC/MAC) of EOLs\r\n    562         if default is None:\r\n--> 563                 assert file_exists(location), \"cuisine.file_read: file does not exists {0}\".format(location)\r\n    564         elif not file_exists(location):\r\n    565                 return default\r\n\r\nAssertionError: cuisine.file_read: file does not exists /path/doesnt/exists\r\n```\r\n\r\nor with a empty config file\r\n```\r\nnginx =  j.ssh.nginx.get(cl, '/opt/nginx/cfg/sites-enabled/ovc')\r\n\r\nIn [9]: nginx.config\r\n[localhost:22] run: test -e /opt/nginx/cfg/sites-enabled/ovc && echo OK ; true\r\n[localhost:22] out: OK\r\n[localhost:22] out: \r\n\r\n[localhost:22] run: cat /opt/nginx/cfg/sites-enabled/ovc | openssl base64\r\n---------------------------------------------------------------------------\r\nParseException                            Traceback (most recent call last)\r\n/usr/local/bin/js in <module>()\r\n----> 1 nginx.config\r\n\r\n/opt/jumpscale7/lib/JumpScale/lib/ssh/nginx/manager.pyc in config(self)\r\n     32         if self._config is None:\r\n     33             content = self._con.file_read(self._path)\r\n---> 34             self._config = NginxConfig(content)\r\n     35         return self._config\r\n     36 \r\n\r\n/opt/jumpscale7/lib/JumpScale/lib/ssh/nginx/manager.pyc in __init__(self, content)\r\n     61         self.events = None\r\n     62         import nginxparser\r\n---> 63         config = nginxparser.loads(content)\r\n     64         super(NginxConfig, self).__init__(config)\r\n     65         if self.http is None:\r\n\r\n/opt/jumpscale7/lib/nginxparser.pyc in loads(source)\r\n     99 \r\n    100 def loads(source):\r\n--> 101     return NginxParser(source).as_list()\r\n    102 \r\n    103 \r\n\r\n/opt/jumpscale7/lib/nginxparser.pyc in as_list(self)\r\n     47         Returns the list of tree.\r\n     48         \"\"\"\r\n---> 49         return self.parse().asList()\r\n     50 \r\n     51 \r\n\r\n/opt/jumpscale7/lib/nginxparser.pyc in parse(self)\r\n     41         Returns the parsed tree.\r\n     42         \"\"\"\r\n---> 43         return self.script.parseString(self.source)\r\n     44 \r\n     45     def as_list(self):\r\n\r\n/opt/jumpscale7/lib/pyparsing.pyc in parseString(self, instring, parseAll)\r\n   1123             else:\r\n   1124                 # catch and re-raise exception from here, clears out pyparsing internal stack trace\r\n-> 1125                 raise exc\r\n   1126         else:\r\n   1127             return tokens\r\n\r\nParseException: Expected W:(abcd...) (at char 0), (line:1, col:1)\r\n```"}}