{"id":26866466,"url":"https://github.com/mtconnect/py_agent","last_synced_at":"2025-05-07T01:23:37.797Z","repository":{"id":9941493,"uuid":"11958194","full_name":"mtconnect/py_agent","owner":"mtconnect","description":"Python Agent","archived":false,"fork":false,"pushed_at":"2020-11-14T16:04:48.000Z","size":168,"stargazers_count":16,"open_issues_count":2,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T04:54:38.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtconnect.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-07T19:11:15.000Z","updated_at":"2021-01-07T09:07:24.000Z","dependencies_parsed_at":"2022-09-13T14:51:05.134Z","dependency_job_id":null,"html_url":"https://github.com/mtconnect/py_agent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtconnect%2Fpy_agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtconnect%2Fpy_agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtconnect%2Fpy_agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtconnect%2Fpy_agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtconnect","download_url":"https://codeload.github.com/mtconnect/py_agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252794380,"owners_count":21805188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-31T04:54:42.552Z","updated_at":"2025-05-07T01:23:37.751Z","avatar_url":"https://github.com/mtconnect.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"py_agent\n========\n\n### Just getting started w/ Python Agent\n\nSo we're going to try to use Flask for the Python Agent. Flask is a microframework for Python based on Werkzeug and Jinja 2. We'll also be using Flask-RESTful an extension to Flask. Obviously this is all subject to change, but this can be a good start for the Python Agent. Flask depends on two external libraries, Werkzeug and Jinja2. Werkzeug is a toolkit for WSGI, the standard Python interface between web applications and a variety of servers for both development and deployment. Jinja2 renders templates. So how do we get all that installed simply and quickly. There are a couple ways to do this, but probably the best way is to do a virtualenv(virtual environment). Most of the information described can be found on the Flask docs site.\n\n###virtualenv and installing Flask\n\nVirtualenv enables multiple side-by-side installations of Python, one for each project. It doesn’t actually install separate copies of Python, but it does provide a great way to keep different project environments isolated. See below how a virtualenv works.\n\nIf you are on Mac OS X or Linux, chances are that one of the following two commands will work for you:\n\n```\n$ sudo easy_install virtualenv\n```\n\nor\n\n```\n$ sudo pip install virtualenv\n```\n\nOne of these will probably install virtualenv on your system. Maybe it’s even in your package manager. If you use Ubuntu, try:\n\n```\n$ sudo apt-get install python-virtualenv\n```\n\nIf you are using Windows please scroll down to the Windows Users section to see how to install.\n\nOnce you have the virtualenv installed, open up terminal (aka a shell) and create your own environment. You can create a project folder then a venv folder within that folder:\n\n```\n$ mkdir myproject\n$ cd myproject\n$ virtualenv venv\nNew python executable in venv/bin/python\nInstalling distribute............done.\n```\n\nOk, whenever you want to work on a project, you only have to activate the corresponding environment. On OS X and Linux, do the following:\n\n```\n$ . venv/bin/activate\n```\n\nIf you are a Windows user, use the following command:\n\n```\n$ venv\\scripts\\activate\n```\n\nNow, you should now be using your virtualenv (notice how the prompt of your shell has changed to show the active environment).\n\nNow you can just enter the following command to get Flask activated in your virtualenv:\n\n```\n$ pip install Flask\n```\n\nAnd there you go, at least with getting Flask installed. Next we'll need to install Flask-RESTful.\n\n###installing Flask-RESTful\n\nInstall Flask-RESTful with pip\n\n```\npip install flask-restful\n```\n\nFlask-RESTful has the following dependencies (which will be automatically installed if you use pip):\n\nFlask version 0.8 or greater\nFlask-RESTful requires Python version 2.6, 2.7, or 3.3.\n\nNow, after all that is done, we are ready to start the Agent. To do this make sure you are in the project folder that we created above and make sure you have activated your virtual environment. Now run the command below:\n\n```\npython agent.py\n```\n\nThere you have it! Your agent should be running at 127.0.0.1:5000 (aka http://localhost:5000)\n\n###Windows Users\n\nOn Windows, installation of easy_install is a little bit trickier, but still quite easy. The easiest way to do it is to download the distribute_setup.py file and run it. The easiest way to run the file is to open your downloads folder and double-click on the file.\n\nNext, add the easy_install command and other Python scripts to the command search path, by adding your Python installation’s Scripts folder to the PATH environment variable. To do that, right-click on the “Computer” icon on the Desktop or in the Start menu, and choose “Properties”. Then click on “Advanced System settings” (in Windows XP, click on the “Advanced” tab instead). Then click on the “Environment variables” button. Finally, double-click on the “Path” variable in the “System variables” section, and add the path of your Python interpreter’s Scripts folder. Be sure to delimit it from existing values with a semicolon. Assuming you are using Python 2.7 on the default path, add the following value:\n\n```\n;C:\\Python27\\Scripts\n```\n\nAnd you got it! To check that it worked, open the Command Prompt and execute easy_install. If you have User Account Control enabled on Windows Vista or Windows 7, it should prompt you for administrator privileges.\n\nNow that you have easy_install, you can use it to install pip:\n\n```\n\u003e easy_install pip\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtconnect%2Fpy_agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtconnect%2Fpy_agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtconnect%2Fpy_agent/lists"}