Comments (15)
Идея хорошая, но что лучше? На автомате по текущему SHELL или же опцией -s zshrc
from ahc.
Я думаю лучше определять текущий shell автоматом, далее задать вопрос на подтверждение, в случае -s zshrc - не делать данную проверку
from ahc.
Теперь доступна опция -s shell, и там уже автоматом в домашнюю директорию поставится zshrc или bashrc. В зависимости от переменной окружения.
Опция -s bashrc - удалена.
Попробуйте на Вашей машине.
from ahc.
Есть проблема в том, что хоть shell и определяется корректно, но вместо создания .zshrc заменяется .bashrc
~ root@localhost > echo $SHELL
/bin/zsh
~ root@localhost > ahc -m install -s shell
~ root@localhost >
~ root@localhost > find ~ -name ".zshrc"
~ root@localhost >
~ root@localhost > cat .bashrc
# http://brokenbrake.biz/2010/08/03/.zshrc
.........
from ahc.
а можешь попробовать запустить python в консоли и набрать:
import os
print 'python env shell: %s' % os.getenv('SHELL')
os.system('echo $SHELL')
и тоже самое сделать создав файл:
test.py с таким же содержанием. а после выполнить python test.py
и stdout в студию)
from ahc.
Да, вот вывод.
~ root@localhost > python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print 'python env shell: %s' % os.getenv('SHELL')
python env shell: /bin/zsh
>>> os.system('echo $SHELL')
/bin/zsh
0
>>>
~ root@localhost > python ./test.py
python env shell: /bin/zsh
/bin/zsh
~ root@localhost >
from ahc.
если в файле modules/install.py на 28 строчке изменить .bashrc на .zshrc - измениться ситуация? Это моя опечатка. Если да, то закомичу
from ahc.
нет, похоже проблема в чем то другом, так как все ровно создается .bashrc.
добавил вывод после 28-ой строчки
print 'python env shell: %s' % os.getenv('SHELL')
но текст так в консоль не вывелся, хотя после 22-ой тоже не выводится.
Рекомендую в этом пункте использовать switch-case, так как есть еще несколько популярных интерпретаторов, а дефолтный выбрать - баш
from ahc.
правильно там откешированно все. выполни:
find /usr/lib/ahc ( -name '.pyc' -or -name '.pyo' ) -delete
from ahc.
хм, сделал, но проблема осталась:
/usr/src/ahc root@localhost > echo $SHELL
/bin/zsh
/usr/src/ahc root@localhost > mv ~/.bashrc ~/bashrc_backup
/usr/src/ahc root@localhost > mv ~/.zshrc ~/zshrc_backup
/usr/src/ahc root@localhost > find /usr/lib/ahc -name '.pyc' -or -name '.pyo' -delete
/usr/src/ahc root@localhost > ahc -m install -s shell
/usr/src/ahc root@localhost > find ~ -name '.bashrc'
/root/.bashrc
/usr/src/ahc root@localhost > find ~ -name '.zshrc'
/usr/src/ahc root@localhost >
from ahc.
Будучи в своей оболочке:
$ ahc -m install -s shell
Shell config for "/bin/bash" successfully installed.
И под zsh:
~ root@gotlium > head -2 ~/.zshrc
TESTING
http://brokenbrake.biz/2010/08/03/.zshrc
~ root@gotlium > ahc -m install -s shell
Shell config for "/bin/zsh" successfully installed.
~ root@gotlium > head -2 ~/.zshrc
http://brokenbrake.biz/2010/08/03/.zshrc
Метод изменился на подобное:
def shell(self):
home = os.getenv('HOME')
shell = os.getenv('SHELL')
if shell.find('/bash') != -1:
configuration = getTemplate('bashrc')
filename = '%s/.bashrc' % home
elif shell.find('/zsh') != -1:
configuration = getTemplate('zshrc')
filename = '%s/.zshrc' % home
else:
error_message('Sorry, your shell not supported!')
if fileExists(filename):
backFile(filename)
putFile(filename, configuration)
info_message('Shell config for "%s" successfully installed.' % shell)
Только осторожнее с отступами
from ahc.
Там условия группировать надо. Попробуй тогда просто pyo файлы удалить:
$ find /usr/lib/ahc -name '.pyo' -delete
from ahc.
Не помогло((. Странно, что info_message('Shell config for "%s" successfully installed.' % shell) на 35-ой строчке не отрабатывает.
/usr/src/ahc root@localhost > head -35 modules/install.py
__author__ = 'gotlium'
import MySQLdb
import getpass, pwd
import os
from libraries.helpers import *
from libraries.apache import CertificateGenerator
class Install(object):
def __init__(self, base):
self.base = base
self.methods = ('service',)
def certs(self):
cert = CertificateGenerator(self.base)
if cert.createDatabase():
info_message('"Apache SSL Certs Protection" was successfully installed.')
def shell(self):
home = os.getenv('HOME')
shell = os.getenv('SHELL')
if shell.find('/bash') != -1:
configuration = getTemplate('bashrc')
filename = '%s/.bashrc' % home
elif shell.find('/zsh') != -1:
configuration = getTemplate('zshrc')
filename = '%s/.zshrc' % home
else:
error_message('Sorry, your shell not supported!')
if fileExists(filename):
backFile(filename)
putFile(filename, configuration)
info_message('Shell config for "%s" successfully installed.' % shell)
/usr/src/ahc root@localhost > find ~ -name '.zshrc'
/usr/src/ahc root@localhost > find /usr/lib/ahc -name '.pyc' -delete
/usr/src/ahc root@localhost > find /usr/lib/ahc -name '.pyo' -delete
/usr/src/ahc root@localhost > ahc -m install -s shell
/usr/src/ahc root@localhost > find ~ -name '.zshrc'
/usr/src/ahc root@localhost >
from ahc.
Давай попробуем удалить проект и снова склонировать его. Уж больно странно все это. Такого поведения не должно быть! Только забэкапь конфиг. Учти что это символьная ссылка на /usr/lib/ahc/configs.cfg
$ rm -rf /usr/src/ahc/
$ cd /usr/src/ && git clone https://github.com/gotlium/ahc.git
$ cd ./ahc/
$ make remove
$ make install
from ahc.
Отрабатывает, пасиб
from ahc.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ahc.