You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/12/02 17:41:12 UTC

[GitHub] [trafficcontrol] zrhoffman opened a new issue #6394: TO Postinstall: NameError: name 'Pg' is not defined

zrhoffman opened a new issue #6394:
URL: https://github.com/apache/trafficcontrol/issues/6394


   <!--
   ************ STOP!! ************
   If this issue identifies a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Traffic Control Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://apache.org/security regarding vulnerability disclosure.
   
   - For *SUPPORT QUESTIONS*, use the #traffic-control channel on the ASF slack (https://s.apache.org/tc-slack-request)
   or the Traffic Control Users mailing list (send an email to users-subscribe@trafficcontrol.apache.org to subscribe).
   - Before submitting, please **SEARCH GITHUB** for a similar issue or PR
       * https://github.com/apache/trafficcontrol/issues
       * https://github.com/apache/trafficcontrol/pulls
   -->
   
   <!-- Do not submit security vulnerabilities or support requests here - see above -->
   ## This Bug Report affects these Traffic Control components:
   <!-- delete all those that don't apply -->
   - Traffic Ops - Postinstall
   
   ## Current behavior:
   <!-- Describe how the bug happens -->
   Running the Postinstall script using terminal (instead of `input.json`) input under Python 2 fails:
   ```python
   [user@host trafficcontrol]$ cd traffic_ops/install/bin
   [user@host bin]$ <<<Pg sudo python2 _postinstall.py
   INFO:root:Starting postinstall
   INFO:root:Debug is on
   INFO:root:No input file given - using defaults
   INFO:root:===========/opt/traffic_ops/app/conf/production/database.conf===========
   Database type [Pg]: Traceback (most recent call last):
     File "_postinstall.py", line 1528, in <module>
       ARGS.no_database
     File "_postinstall.py", line 1293, in main
       dbconf = generate_db_conf(user_input[DATABASE_CONF_FILE], DATABASE_CONF_FILE, automatic, root_dir)
     File "_postinstall.py", line 330, in generate_db_conf
       db_conf = get_config(qstns, fname, automatic)
     File "_postinstall.py", line 318, in get_config
       answer = question.default if automatic else question.ask()
     File "_postinstall.py", line 146, in ask
       ipt = input(self)
     File "<string>", line 1, in <module>
   NameError: name 'Pg' is not defined
   ```
   
   ## Expected behavior:
   <!-- Describe what the behavior would be without the bug -->
   Running the Postinstall script using terminal (instead of `input.json`) input under Python 2 should succeed and have test coverage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on issue #6394: TO Postinstall: NameError: name 'Pg' is not defined

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on issue #6394:
URL: https://github.com/apache/trafficcontrol/issues/6394#issuecomment-985074935


   This is because in The Dead Language, `input` is compiling and running the received input as though it were a Python script. So, equivalently `eval("Pg")`. The Dead Language's equivalent of `input` is `raw_input`, but that returns a `str` not a `unicode` which is what `str` is redefined to, so there also needs to be a cast there. Probably needs a shim like
   ```python2
   if language_is_dead:
       def input(*args):
           if len(args) > 1:
               raise TypeError("input expected at most 1 argument, got " + str(len(args)))
           return unicode(raw_input(*args))
   ``` 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 edited a comment on issue #6394: TO Postinstall: NameError: name 'Pg' is not defined

Posted by GitBox <gi...@apache.org>.
ocket8888 edited a comment on issue #6394:
URL: https://github.com/apache/trafficcontrol/issues/6394#issuecomment-985074935


   This is because in The Dead Language, `input` is compiling and running the received input as though it were a Python script. So, equivalently `eval("Pg")`. The Dead Language's equivalent of `input` is `raw_input`, but that returns a `str` not a `unicode` which is what `str` is redefined to, so there also needs to be a cast there. Probably needs a shim like
   ```python
   if language_is_dead:
       def input(*args):
           if len(args) > 1:
               raise TypeError("input expected at most 1 argument, got " + str(len(args)))
           return unicode(raw_input(*args))
   ``` 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org