...
Just my blog

Blog about everything, mostly about tech stuff I made. Here is the list of stuff I'm using at my blog. Feel free to ask me about implementations.

Soft I recommend
Py lib I recommend

I'm using these libraries so you can ask me about them.

Django, Apache2, Sublime Text 3 build system and developing process.

At first be sure that you are using this path to run pure apache: http://www.trianglesis.org.ua/django-python-3-4-wamp-apache-2-4-23-pycharm

This topic for those who wants to develop ON THE FLY with python and django and do not want to manually restart dev server each time when code changes AND you don't like built in python web-server and want to run your dev site as it should run on apache.

 

Sublime Text 3

I use it for fast code changing and writting because PyCharm can't work fine with multiline carrets, for example. Also PyCharm is too heavy when you want just copy&paste some features and see how it work on web. So my PyCharm will be used for debug purposes.

I hope you know what is the "Build system" in Sublime, if no - read this first: http://sublimetext.info/docs/en/reference/build_systems.html

  1. Should run Sublime text 3 "as Administrator"
    1. You can run it once with Shift + Left mouse
    2. You can switch settings on sublime_text.exe (Compatibilities -> Always run as Admin.)
  2. Then in Sublime: Tools -> Build System -> New Build System
    1. In opened file just copy&pase my example content
    2. Change paths to your programms: Chrome, IE etc...
    3. Save file with name like Apache.sublime-build
  3. Create .bat files from my examples
    1. Place it where you want 
    2. Changes paths in build file to correspond bat file for each option you want
  4. Use simply with Ctrl + Shift + P type "name" of your build option.

If there is no Build system (Apache in my example)  added in list: Tools -> Build System - it happened because build file is not in place: 

  • C:\Users\Username\AppData\Roaming\Sublime Text 3\Packages\User\Apache.sublime-build

If Build system is in the list, but not in console (Ctrl + Shift + P -> Build With Apache...) - it means that build file has a syntax error, check every bracket and comma from my example.

Bat files

I have different options for build:

  • Can restart apache - only from cmd with Sublime
  • Can restart apache via .bat with Sublime
  • Can restart apache via .bat AND open http://adress in web-browser
    • restarting apache and open link can be used via bat only, I did no found the way to open it in sublime-build options

So, when you compose .bat file for open address after apache restarted - use command-line args in bat: 

set arg1=%1
C:\wamp\bin\apache\apache2.4.23\bin\httpd.exe -k restart && "C:\Progra~2\Google\Chrome\Application\chrome.exe" http://dev.site:8080/%arg1%/

 And then add this args (url paths) to build option:

// BAT Restart Apache THEN open IE /date/ 
{ "name": ".bat Restart Apache THEN Open IE /date/",
  "cmd": [
          "D:\\Projects\\CODE\\WEB\\sites\\www\\smm_tools\\conf\\restart_apache_open_IE.bat",
          "date"
         ]
  
},

 That's all!

When everything is fine - after you choose any build option - Apache will be restarted and web-browser will open page you want.

Examples:

Apache.sublime-build

{
    "selector": "source.py",
    "cmd": ["C:\\wamp\\bin\\apache\\apache2.4.23\\bin\\httpd.exe", "-k", "restart"],
    "working_dir": "C:\\Windows\\System32",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "variants": [


        // Restart Apache
        { "name": "Restart Apache",
          "cmd": [
                  "C:\\wamp\\bin\\apache\\apache2.4.23\\bin\\httpd.exe", "-k", "restart"
                 ]
        },


        // BAT Restart Apache 
        { "name": ".bat Restart Apache",
          "cmd": [
                  "D:\\restart_apache.bat"
                 ]
          
        },

        // BAT Restart Apache Open /date/ 
        { "name": ".bat Restart Apache Open /date/",
          "cmd": [
                  "D:\\restart_open_date.bat"
                 ]
          
        },

        // BAT Restart Apache THEN open IE /date/ 
        { "name": ".bat Restart Apache THEN Open IE /date/",
          "cmd": [
                  "D:\\restart_apache_open_IE.bat",
                  "date"
                 ]
          
        },

        // BAT Restart Apache THEN open Chrome /date/ 
        { "name": ".bat Restart Apache THEN Open Chrome /date/",
          "cmd": [
                  "D:\\restart_apache_open_Chrome.bat",
                  "date"
                 ]
          
        },

        // { "name": "Dummy",
        //   "cmd": ["Dummy"]
        // }


    ]
}

 restart_apache.bat

C:\wamp\bin\apache\apache2.4.23\bin\httpd.exe -k restart

restart_apache_open_Chrome.bat

set arg1=%1
C:\wamp\bin\apache\apache2.4.23\bin\httpd.exe -k restart && "C:\Progra~2\Google\Chrome\Application\chrome.exe" http://dev.site:8080/%arg1%/

restart_apache_open_IE.bat

set arg1=%1
C:\wamp\bin\apache\apache2.4.23\bin\httpd.exe -k restart && "C:\Progra~1\Internet Explorer\iexplore.exe" http://dev.site:8080/%arg1%/