Solution fo "LookupError: unknown encoding: A" when running Trac 1.2 on WIndows with Python 2.6.x

When installing & running standalone Trac 1.2.x on Windows, an error could happen after you firstly visit your Trac website:

LookupError: unknown encoding: A

It's probably caused by messy encoding issue of your Windows CMD environment.

There is a simple workaround to resolve this issue. Check the error message, and trace back to site-packages\trac\util\datefmt.py, function _format_datetime_without_babel(t, format)

You can see the final encoding is determined by 3 possible sources:

encoding = getlocale(LC_TIME)[1] or getpreferredencoding() or sys.getdefaultencoding()

If you try to import appropriate modules and print out these source, the results can help you understanding exact what encoding could be used.  In my case, the results are empty, "cp950", and "ascii" respectively.

Encoding "cp950" usually causes painful issues when executing Python code...

So, the workaround is to comment the original encoding retrieval statement, and use system default encoding  instead:

#encoding = getlocale(LC_TIME)[1] or getpreferredencoding() or sys.getdefaultencoding()
encoding = sys.getdefaultencoding()

Stop and restart tracd.exe, and it should get you the Trac project selection frontpage.


ERR_TOO_MANY_REDIRECTS on Prestashop 1.7.0.4 Installation with LAMP

Trouble shooting for ERR_TOO_MANY_REDIRECTS  error when installing Prestashop with LAMP environment.

Problem:


Workaround Solution:
  • Installing Prestashop 1.7 on WAMP in another Windows machine or virtual machine
  • Migrate Prestashop 1.7 on WAMP to LAMP in your target machine

Not a perfect solution. At least it worked for me.

Migrating fresh Prestashop from WAMP to LAMP


Original package and environment :

  • Prestashop 1.7.0.4
  • WAMP server 64 bit 3.0.6
  • Windows 10

Target package and environment :
  • Prestashop 1.7.0.4 (the same as original package)
  • LAMP - Ubuntu 16.04, Apache2.4, MySQL 5.7.17, PHP 7

Migration  procedure :
  1. Exporting Prestashop database from WAMP as .sql or whatever format you prefer
  2. Importing Prestashop database into LAMP
    • Make sure your Prestashop database on LAMP allows the same access permisson as that of Prestashop on WAMP
  3. Packing Prestashop installation folder from WAMP as .zip or whatever format you prefer
  4. Unzip and deploy Prestashop in LAMP (ex. /var/www/html/prestashop )
  5. Turn on the development mode of Prestashop
    • Edit prestashop/config/defines.inc.php, alter define('_PS_MODE_DEV_', false) to true
  6. Start LAMP and browsing your migrated Prestashop website
    • It is possible that some PHP module needs to be installed and turned on. Just following the error messages and do what you have to do.
    • If you encounter an issue that front-end shows empty pages :
      • remove .htaccess in your /var/www/html/prestashop
      • enter your Prestashop backend, find friendly URL option in configure => shop parameters => traffic => SEO, slide down, turn off friendly URL option, and save to regenerate .htaccess
    •  If you encounter an issue that your connection is always redirected to localhost :
      • enter your Prestashop MySQL DB, alter PS_SHOP_DOMAIN and PS_SHOP_DOMAIN_SSL from localhost to specified IP or domain
      • enter your Prestashop backend, find configure => shop parameters => traffic => SEO, slide down, alter domain and domain_ssl from localhost to specified IP or domain
  7. Done

Taiga Installation Troubleshootings

Installation assumptions :


Back-end Issue :

  • django.db.utils.OperationalError: FATAL:  Peer authentication failed for user "taiga"
    • check your settings/local.py for password configuration of user "taiga"
    • If that doesn't work
      • check your /etc/postgresql/9.x/main/pg_hba.conf
      • revise the line "local all taiga peer" from space-based separation to tab-based separation
      • service postgresql restart

Front-end Issue :

  • No such file or directory -- /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/rake when installing scss-lint
    • find your rake command (using whereis command maybe)
    • in my case the rake command is found in /usr/bin/rake
    • create directory /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/
    • soft-link /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/rake to /usr/bin/rake
    • re-install scss-lint as instruction

Django Background Tasks Installation & Migration

* 注意以下是使用延續開發的 Django-Background-Tasks 而不是舊版的 Django-Background-Task

Installation 按照 Django-Background-Tasks GitHub 上的說明就沒問題, 但是要注意的是說明中沒有提到 DB Migration 的步驟, 可能這是常識了 ?

如果沒做 DB Migration 的話, 直接嘗試寫 example code 執行會出現類似以下的錯誤訊息:

"django.db.utils.OperationalError: no such table: background_task"

也就是 DB 中找不到 background_task table

這時候回頭去做 makemigrations 會發現...

還是出現了 "django.db.utils.OperationalError: no such table: background_task"  !!!

這個原因與 stackoverflow 上可以查到的 不相同, 該例子是使用 makemigrations background_task 指定要變動的 package 就可以解決.

真正的原因出在 example code 撰寫中可能牽涉到的調用  background_task table 的部分. 在我的例子中, 是 example code 在 views.py 中加入了 import MyApp.routine_tasks  ( routine_tasks.py 是我用來放預計要背景執行的工作 ), 而  routine_tasks.py 中又有 from background_task import background , 所以就出現問題了~

結論: 進行 makemigration 要在加入了相關 code 之前進行

1. Install & set settings.py
2. do makemigrations & migrate before add any example code
3. add example code 


Designed by Posicionamiento Web | Modified by seLain | Bloggerized by GosuBlogger | Blue Business Blogger