mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-05 23:20:19 +00:00
1 line
5.5 KiB
JSON
1 line
5.5 KiB
JSON
[{"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301203949.5253119, "message": "Example: 127.0.0.1 myhost on /etc/host, is possible used python or exists a module", "group_id": 292, "id": 449576}, {"user_id": 1736, "stars": [], "topic_id": 15575, "date_created": 1301204398.069571, "message": "Your question doesn't make sense as asked. Are you trying to do system configuration or something?", "group_id": 292, "id": 449604}, {"user_id": 2851, "stars": [], "topic_id": 15575, "date_created": 1301213973.20803, "message": "The hosts file is just a regular file, so with proper permissions you can use Python's built in file I/O", "group_id": 292, "id": 450072}, {"user_id": 4077, "stars": [], "topic_id": 15575, "date_created": 1301266661.4175589, "message": "If it's a one-time application, you might just add the line to hosts manually. If it's for system configuration, I'd recommend looking into puppet, or something similar. If it's a webapp that you're trying to modify hosts with, you probably shouldn't. If you have web accessible code that can write to /etc/hosts, you're asking for trouble.", "group_id": 292, "id": 453287}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301275224.7205291, "message": "@coderanger No, I want create a python script similar to ghost - https://github.com/bjeanes/ghost", "group_id": 292, "id": 453985}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301275521.6606381, "message": "@bmelton Not for a web application is for a desktop app. I want to automate the update of / etc / hosts in MEPP - https://github.com/jyr/MEPP", "group_id": 292, "id": 454008}, {"user_id": 10411, "stars": [], "topic_id": 15575, "date_created": 1301284305.2560229, "message": "@jyr Then the user needs permission to edit /etc/hosts.", "group_id": 292, "id": 454686}, {"user_id": 1736, "stars": [{"date_created": 1301287746.990932, "user_id": 10411}], "topic_id": 15575, "date_created": 1301284702.418056, "message": "Which would probably be bad", "group_id": 292, "id": 454722}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301287610.758894, "message": "@scopatz it not problem, I have permission to edit. How can get matching string of /etc/hosts?", "group_id": 292, "id": 455099}, {"user_id": 1736, "stars": [], "topic_id": 15575, "date_created": 1301287795.722832, "message": "@jyra the hosts file doesn't have that complex a syntax.", "group_id": 292, "id": 455156}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301289239.9928579, "message": "@coderanger sorry, I work with OS X 10.6 and if have the file hosts. So, How can find string on hosts file?", "group_id": 292, "id": 455374}, {"user_id": 10411, "stars": [], "topic_id": 15575, "date_created": 1301287758.9701271, "message": "@coderanger Yes which would be!", "group_id": 292, "id": 455146}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301288005.7815731, "message": "basically, I need add and remove hosts from a command for example: python pyhost.py add 127.0.0.1 mysite.local", "group_id": 292, "id": 455206}, {"user_id": 1736, "stars": [], "topic_id": 15575, "date_created": 1301288607.660888, "message": "@jyr On a Linux system /etc/hosts will be owned by root and usually 0644, and OS X doesn't even have an /etc/hosts anymore", "group_id": 292, "id": 455289}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301287838.240294, "message": "@coderanger not bad, runs locally and for the user.", "group_id": 292, "id": 455171}, {"user_id": 1, "stars": [], "topic_id": 15575, "date_created": 1301289375.0522399, "message": "@jyr I don't quite understand the question.", "group_id": 292, "id": 455387}, {"user_id": 1, "stars": [], "topic_id": 15575, "date_created": 1301289699.618804, "message": "@jyr Here's a little untested Python script that helps get the ip/name pairs:", "group_id": 292, "id": 455427}, {"user_id": 1, "stars": [], "topic_id": 15575, "date_created": 1301289807.7301321, "message": "e.g. to print it out in a structured way, you could do this:", "group_id": 292, "id": 455441}, {"user_id": 1, "stars": [{"date_created": 1301293172.222682, "user_id": 6541}], "topic_id": 15575, "date_created": 1301289808.550988, "message": "with open('/etc/hosts', 'r') as hosts_file:\n for line in hosts_file:\n split_line = [s.strip() for s in line.split()]\n # skip over malformed /etc/hosts entries\n if len(split_line) < 2:\n continue\n ip, hostnames = split_line[0], split_line[1:]\n print {'ip': ip, 'hostnames': hostnames}", "group_id": 292, "id": 455442}, {"user_id": 1, "stars": [], "topic_id": 15575, "date_created": 1301289702.4306431, "message": "with open('/etc/hosts', 'r') as hosts_file:\n for line in hosts_file:\n split_line = [s.strip() for s in line.split()]\n # skip over malformed /etc/hosts entries\n if len(split_line) < 2:\n continue\n ip, hostnames = split_line[0], split_line[1:]\n ####\n # Do something with each ip/hostname pairing\n ####\n", "group_id": 292, "id": 455428}, {"user_id": 6541, "stars": [], "topic_id": 15575, "date_created": 1301292465.302268, "message": "@ericflo ok, I will try of snippet thanks", "group_id": 292, "id": 455604}, {"user_id": 25106, "stars": [], "topic_id": 15575, "date_created": 1301320139.8734441, "message": "You'll want to ignore comments, which can appear anywhere in a line and start with #, like Python. A regex substitution before splitting the line should work.", "group_id": 292, "id": 457874}] |