Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
e4d074fc
Commit
e4d074fc
authored
Oct 16, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Jan 16, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: use six.moves.urllib for compatibility.
parent
796fab2e
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
151 additions
and
88 deletions
+151
-88
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5AccessToken.py
...teItem/portal_components/test.erp5.testERP5AccessToken.py
+2
-2
bt5/erp5_authentication_policy/TestTemplateItem/portal_components/test.erp5.testAuthenticationPolicy.py
...m/portal_components/test.erp5.testAuthenticationPolicy.py
+3
-3
bt5/erp5_barcode/ExtensionTemplateItem/portal_components/extension.erp5.Barcode.py
...nTemplateItem/portal_components/extension.erp5.Barcode.py
+1
-1
bt5/erp5_commerce/ExtensionTemplateItem/portal_components/extension.erp5.Ecommerce.py
...emplateItem/portal_components/extension.erp5.Ecommerce.py
+2
-2
bt5/erp5_commerce/TestTemplateItem/portal_components/test.erp5.testERP5Commerce.py
...plateItem/portal_components/test.erp5.testERP5Commerce.py
+6
-6
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testAutoLogout.py
...emplateItem/portal_components/test.erp5.testAutoLogout.py
+2
-2
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
...eItem/portal_components/test.erp5.testBusinessTemplate.py
+1
-1
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testCookieCrumbler.py
...ateItem/portal_components/test.erp5.testCookieCrumbler.py
+2
-2
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Core.py
...tTemplateItem/portal_components/test.erp5.testERP5Core.py
+2
-3
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
...s/TestTemplateItem/portal_components/test.erp5.testDms.py
+5
-4
bt5/erp5_free_subscription/TestTemplateItem/portal_components/test.erp5.testFreeSubscription.py
...eItem/portal_components/test.erp5.testFreeSubscription.py
+1
-1
bt5/erp5_knowledge_pad/ExtensionTemplateItem/portal_components/extension.erp5.GetRssDataAsDict.py
...Item/portal_components/extension.erp5.GetRssDataAsDict.py
+4
-4
bt5/erp5_palo/DocumentTemplateItem/portal_components/document.erp5.PALOETLConnection.py
...Item/portal_components/document.erp5.PALOETLConnection.py
+2
-2
bt5/erp5_paypal_secure_payment/DocumentTemplateItem/portal_components/document.erp5.PaypalService.py
...lateItem/portal_components/document.erp5.PaypalService.py
+2
-2
bt5/erp5_rss_reader/ExtensionTemplateItem/ERP5RSSFeed.py
bt5/erp5_rss_reader/ExtensionTemplateItem/ERP5RSSFeed.py
+61
-0
bt5/erp5_run_my_doc/ExtensionTemplateItem/portal_components/extension.erp5.ERP5RunMyDocs.py
...ateItem/portal_components/extension.erp5.ERP5RunMyDocs.py
+2
-2
bt5/erp5_short_message/DocumentTemplateItem/portal_components/document.erp5.EssendexGateway.py
...teItem/portal_components/document.erp5.EssendexGateway.py
+13
-12
bt5/erp5_short_message/DocumentTemplateItem/portal_components/document.erp5.MobytGateway.py
...plateItem/portal_components/document.erp5.MobytGateway.py
+8
-7
bt5/erp5_sso_openam/ExtensionTemplateItem/portal_components/extension.erp5.OpenAMLogout.py
...lateItem/portal_components/extension.erp5.OpenAMLogout.py
+2
-2
bt5/erp5_test_result/DocumentTemplateItem/portal_components/document.erp5.GitlabRESTConnector.py
...em/portal_components/document.erp5.GitlabRESTConnector.py
+1
-1
bt5/erp5_ui_test_core/ExtensionTemplateItem/portal_components/extension.erp5.ERP5Zuite.py
...emplateItem/portal_components/extension.erp5.ERP5Zuite.py
+2
-2
bt5/erp5_web/DocumentTemplateItem/portal_components/document.erp5.StaticWebSection.py
...eItem/portal_components/document.erp5.StaticWebSection.py
+2
-2
bt5/erp5_wechat_secure_payment/DocumentTemplateItem/portal_components/document.erp5.WechatService.py
...lateItem/portal_components/document.erp5.WechatService.py
+6
-5
product/ERP5/tests/erp5_url_checker.py
product/ERP5/tests/erp5_url_checker.py
+5
-5
product/ERP5/tests/testInvalidationBug.py
product/ERP5/tests/testInvalidationBug.py
+2
-2
product/ERP5/tests/utils.py
product/ERP5/tests/utils.py
+1
-1
product/ERP5Type/patches/urllib_opener.py
product/ERP5Type/patches/urllib_opener.py
+9
-9
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+0
-1
product/ERP5Type/tests/testUpgradeInstanceWithOldDataFs.py
product/ERP5Type/tests/testUpgradeInstanceWithOldDataFs.py
+2
-2
No files found.
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5AccessToken.py
View file @
e4d074fc
...
...
@@ -31,7 +31,7 @@ from ZPublisher.HTTPRequest import HTTPRequest
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
Products.PluggableAuthService.interfaces.plugins
import
IAuthenticationPlugin
from
DateTime
import
DateTime
import
urllib
from
six.moves.urllib.parse
import
urlencode
import
six.moves.http_client
import
base64
from
six.moves
import
cStringIO
as
StringIO
...
...
@@ -140,7 +140,7 @@ class TestERP5AccessTokenSkins(AccessTokenTestCase):
response
=
self
.
publish
(
'/%s/Base_getUserCaption?%s'
%
(
self
.
portal
.
getId
(),
url
lib
.
url
encode
({
urlencode
({
'access_token'
:
access_token
.
getId
(),
'access_token_secret'
:
access_token
.
getReference
()})))
self
.
assertEqual
(
response
.
getStatus
(),
six
.
moves
.
http_client
.
OK
)
...
...
bt5/erp5_authentication_policy/TestTemplateItem/portal_components/test.erp5.testAuthenticationPolicy.py
View file @
e4d074fc
...
...
@@ -755,7 +755,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
response
=
self
.
publish
(
portal
.
absolute_url_path
()
+
'/logged_in'
,
basic
=
'test-05:used_ALREADY_1234'
,
stdin
=
StringIO
(
urllib
.
urlencode
({
'came_from'
:
'https://www.erp5.com'
})),
stdin
=
StringIO
(
six
.
moves
.
urllib
.
parse
.
urlencode
({
'came_from'
:
'https://www.erp5.com'
})),
request_method
=
'POST'
,
)
redirect_url
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
response
.
getHeader
(
"Location"
))
...
...
@@ -818,7 +818,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
def
submit_reset_password_dialog
(
new_password
):
return
self
.
publish
(
'%s/portal_password'
%
self
.
portal
.
getPath
(),
stdin
=
StringIO
(
urllib
.
urlencode
({
stdin
=
StringIO
(
six
.
moves
.
urllib
.
parse
.
urlencode
({
'Base_callDialogMethod:method'
:
''
,
'dialog_id'
:
'PasswordTool_viewResetPassword'
,
'dialog_method'
:
'PasswordTool_changeUserPassword'
,
...
...
@@ -876,7 +876,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
return
self
.
publish
(
'%s/portal_preferences'
%
self
.
portal
.
getPath
(),
basic
=
'%s:current'
%
self
.
id
(),
stdin
=
StringIO
(
urllib
.
urlencode
({
stdin
=
StringIO
(
six
.
moves
.
urllib
.
parse
.
urlencode
({
'Base_callDialogMethod:method'
:
''
,
'dialog_id'
:
'PreferenceTool_viewChangePasswordDialog'
,
'dialog_method'
:
'PreferenceTool_setNewPassword'
,
...
...
bt5/erp5_barcode/ExtensionTemplateItem/portal_components/extension.erp5.Barcode.py
View file @
e4d074fc
...
...
@@ -26,7 +26,7 @@
##############################################################################
import
os
from
urllib
import
urlencode
from
six.moves.urllib.parse
import
urlencode
import
tempfile
from
DateTime
import
DateTime
from
zLOG
import
LOG
...
...
bt5/erp5_commerce/ExtensionTemplateItem/portal_components/extension.erp5.Ecommerce.py
View file @
e4d074fc
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
import
urllib
from
six.moves.urllib.parse
import
urlencode
import
mechanize
def
getProductPrice
(
product
):
...
...
@@ -9,7 +9,7 @@ def getProductPrice(product):
def
submitPaypalNVPRequest
(
parameter_dict
,
nvp_url
):
request
=
mechanize
.
Request
(
nvp_url
)
params
=
url
lib
.
url
encode
(
parameter_dict
)
params
=
urlencode
(
parameter_dict
)
try
:
response
=
mechanize
.
urlopen
(
request
,
data
=
params
)
except
:
...
...
bt5/erp5_commerce/TestTemplateItem/portal_components/test.erp5.testERP5Commerce.py
View file @
e4d074fc
...
...
@@ -30,7 +30,7 @@
import
os
import
string
import
unittest
import
urllib
from
six.moves.urllib.parse
import
quote
from
unittest
import
skip
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
...
@@ -567,14 +567,14 @@ class TestCommerce(ERP5TypeTestCase):
self
.
logout
()
self
.
assertEqual
(
1
,
len
(
self
.
website
.
SaleOrder_getShoppingCartItemList
()))
self
.
website
.
SaleOrder_paymentRedirect
()
self
.
assertIn
(
urllib
.
quote
(
"You need to create an account to "
\
self
.
assertIn
(
quote
(
"You need to create an account to "
\
"continue. If you already have please login."
),
self
.
app
.
REQUEST
.
RESPONSE
.
getHeader
(
'location'
))
# but it should work if the user is authenticated
self
.
loginByUserName
(
'customer'
)
self
.
portal
.
SaleOrder_paymentRedirect
()
self
.
assertIn
(
urllib
.
quote
(
"SaleOrder_viewAsWeb"
),
self
.
assertIn
(
quote
(
"SaleOrder_viewAsWeb"
),
self
.
app
.
REQUEST
.
RESPONSE
.
getHeader
(
'location'
))
def
test_10_deleteShoppingCartItem
(
self
):
...
...
@@ -587,7 +587,7 @@ class TestCommerce(ERP5TypeTestCase):
# Trying to remove
self
.
portal
.
SaleOrder_deleteShoppingCartItem
()
self
.
assertIn
(
urllib
.
quote
(
"Please select an item."
),
self
.
assertIn
(
quote
(
"Please select an item."
),
self
.
app
.
REQUEST
.
RESPONSE
.
getHeader
(
'location'
))
# Check if the item still into the Shopping Cart
...
...
@@ -600,7 +600,7 @@ class TestCommerce(ERP5TypeTestCase):
# Check if the Product have been removed sucessfully
self
.
assertIn
(
urllib
.
quote
(
"Successfully removed from shopping cart."
),
quote
(
"Successfully removed from shopping cart."
),
self
.
app
.
REQUEST
.
RESPONSE
.
getHeader
(
'location'
))
# Check if the Shopping Cart is empty
...
...
@@ -861,7 +861,7 @@ class TestCommerce(ERP5TypeTestCase):
self
.
loginByUserName
(
'toto'
)
self
.
portal
.
SaleOrder_paymentRedirect
()
self
.
assertIn
(
urllib
.
quote
(
"SaleOrder_viewAsWeb"
),
self
.
assertIn
(
quote
(
"SaleOrder_viewAsWeb"
),
self
.
app
.
REQUEST
.
RESPONSE
.
getHeader
(
'location'
))
def
test_23_getShoppingCartCustomer
(
self
):
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testAutoLogout.py
View file @
e4d074fc
...
...
@@ -31,7 +31,7 @@
from
functools
import
partial
from
six.moves
import
cStringIO
as
StringIO
import
unittest
import
urllib
from
six.moves.urllib.parse
import
urlencode
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
DateTime
import
DateTime
try
:
...
...
@@ -75,7 +75,7 @@ class TestAuoLogout(ERP5TypeTestCase):
"""
portal
=
self
.
getPortal
()
stdin
=
url
lib
.
url
encode
({
stdin
=
urlencode
({
'__ac_name'
:
self
.
manager_username
,
'__ac_password'
:
self
.
manager_password
,
})
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
View file @
e4d074fc
...
...
@@ -35,7 +35,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from
Acquisition
import
aq_base
from
App.config
import
getConfiguration
from
Products.ERP5Type.tests.Sequence
import
SequenceList
,
Sequence
from
urllib
import
pathname2url
from
six.moves.urllib.request
import
pathname2url
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
from
Products.ERP5Type.tests.utils
import
LogInterceptor
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testCookieCrumbler.py
View file @
e4d074fc
...
...
@@ -14,7 +14,7 @@
import
base64
from
six.moves
import
cStringIO
as
StringIO
import
unittest
import
urllib
from
six.moves.urllib.parse
import
quote
from
OFS.DTMLMethod
import
DTMLMethod
from
OFS.Folder
import
Folder
...
...
@@ -72,7 +72,7 @@ class ERP5CookieCrumblerTests (CookieCrumblerTests):
self
.
responseOut
=
StringIO
()
self
.
req
=
makerequest
(
root
,
self
.
responseOut
)
self
.
credentials
=
urllib
.
quote
(
self
.
credentials
=
quote
(
base64
.
encodestring
(
'abraham:pass-w'
).
replace
(
'
\
012
'
,
''
))
def
testCookieLongLogin
(
self
):
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Core.py
View file @
e4d074fc
...
...
@@ -31,7 +31,6 @@ import pprint
import
six.moves.http_client
import
six.moves.urllib.parse
import
base64
import
urllib
import
lxml.html
from
AccessControl.SecurityManagement
import
newSecurityManager
...
...
@@ -536,7 +535,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
self
.
assertEqual
(
0
,
person
.
getRelationCountForDeletion
())
def
delete
(
assert_deleted
,
obj
):
redirect
=
self
.
_Folder_delete
(
obj
)
self
.
assertTrue
((
urllib
.
quote
(
'Sorry, 1 item is in use.'
),
'Deleted.'
)[
assert_deleted
]
self
.
assertTrue
((
six
.
moves
.
urllib
.
parse
.
quote
(
'Sorry, 1 item is in use.'
),
'Deleted.'
)[
assert_deleted
]
in
redirect
,
redirect
)
self
.
tic
()
delete
(
0
,
organisation
)
...
...
@@ -565,7 +564,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
document_1
.
manage_permission
(
'View'
,
[],
acquire
=
0
)
document_1
.
manage_permission
(
'Access contents information'
,
[],
acquire
=
0
)
redirect
=
self
.
_Folder_delete
(
document_2
)
self
.
assertTrue
(
urllib
.
quote
(
'Sorry, 1 item is in use.'
)
in
redirect
,
redirect
)
self
.
assertTrue
(
six
.
moves
.
urllib
.
parse
.
quote
(
'Sorry, 1 item is in use.'
)
in
redirect
,
redirect
)
self
.
assertEqual
(
module
.
objectCount
(),
2
)
def
test_getPropertyForUid
(
self
):
...
...
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
View file @
e4d074fc
...
...
@@ -64,7 +64,8 @@ from Products.ERP5Type.Globals import get_request
import
os
from
threading
import
Thread
import
six.moves.http_client
import
urllib
from
six.moves.urllib.request
import
urlopen
from
six.moves.urllib.parse
import
urlencode
import
difflib
import
re
from
AccessControl
import
Unauthorized
...
...
@@ -230,7 +231,7 @@ class TestDocument(TestDocumentMixin):
# __ac=RVJQNVR5cGVUZXN0Q2FzZTo%3D is encoded ERP5TypeTestCase with empty password
url
=
'%s?%s&__ac=%s'
%
(
uri
,
make_query
(
kw
),
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
)
format_
=
kw
.
get
(
'format'
,
'jpeg'
)
infile
=
url
lib
.
url
open
(
url
)
infile
=
urlopen
(
url
)
# save as file with proper incl. format filename (for some reasons PIL uses this info)
filename
=
"%s%stest-image-format-resize.%s"
%
(
os
.
getcwd
(),
os
.
sep
,
format_
)
f
=
open
(
filename
,
"w"
)
...
...
@@ -2357,8 +2358,8 @@ return 1
"""
def
getURL
(
uri
,
**
kw
):
# __ac=RVJQNVR5cGVUZXN0Q2FzZTo%3D is encoded ERP5TypeTestCase with empty password
url
=
'%s?%s&__ac=%s'
%
(
uri
,
url
lib
.
url
encode
(
kw
),
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
)
return
url
lib
.
url
open
(
url
)
url
=
'%s?%s&__ac=%s'
%
(
uri
,
urlencode
(
kw
),
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
)
return
urlopen
(
url
)
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
...
...
bt5/erp5_free_subscription/TestTemplateItem/portal_components/test.erp5.testFreeSubscription.py
View file @
e4d074fc
...
...
@@ -308,7 +308,7 @@ class TestFreeSubscription(ERP5TypeTestCase):
def
stepClickUnsubscriptionLinkInEvent
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
from
urllib
import
urlopen
from
six.moves.urllib.request
import
urlopen
link
=
sequence
[
'unsubscription_link'
]
self
.
logout
()
data
=
urlopen
(
link
)
...
...
bt5/erp5_knowledge_pad/ExtensionTemplateItem/portal_components/extension.erp5.GetRssDataAsDict.py
View file @
e4d074fc
import
feedparser
,
urllib2
,
socket
import
feedparser
,
six
.
moves
.
urllib
.
request
,
six
.
moves
.
urllib
.
error
,
socket
from
hashlib
import
md5
def
getRssDataAsDict
(
context
,
url
,
username
=
None
,
password
=
None
):
...
...
@@ -11,9 +11,9 @@ def getRssDataAsDict(context, url, username=None, password=None):
# use authentication or not?
handlers
=
[]
if
username
is
not
None
and
password
is
not
None
:
passman
=
urllib2
.
HTTPPasswordMgrWithDefaultRealm
()
passman
=
six
.
moves
.
urllib
.
request
.
HTTPPasswordMgrWithDefaultRealm
()
passman
.
add_password
(
None
,
url
,
username
,
password
)
auth_handler
=
urllib2
.
HTTPBasicAuthHandler
(
passman
)
auth_handler
=
six
.
moves
.
urllib
.
request
.
HTTPBasicAuthHandler
(
passman
)
handlers
.
append
(
auth_handler
)
# set shorter timeouts and revert default at enf of read
...
...
@@ -24,7 +24,7 @@ def getRssDataAsDict(context, url, username=None, password=None):
finally
:
socket
.
setdefaulttimeout
(
default_timeout
)
if
d
.
bozo
and
isinstance
(
d
.
bozo_exception
,
urllib2
.
URLError
):
if
d
.
bozo
and
isinstance
(
d
.
bozo_exception
,
six
.
moves
.
urllib
.
error
.
URLError
):
# we have an URL error
return
{
'status'
:
-
2
}
elif
d
.
bozo
:
...
...
bt5/erp5_palo/DocumentTemplateItem/portal_components/document.erp5.PALOETLConnection.py
View file @
e4d074fc
...
...
@@ -26,7 +26,7 @@
##############################################################################
import
suds
import
urllib2
import
six.moves.urllib.request
import
ssl
import
lxml.etree
...
...
@@ -39,7 +39,7 @@ from suds.transport.https import HttpAuthenticated
class
HTTPAuthenticatedUnverifiedSSL
(
HttpAuthenticated
):
def
u2handlers
(
self
):
handlers
=
[
urllib2
.
HTTPSHandler
(
context
=
ssl
.
_create_unverified_context
())
]
handlers
=
[
six
.
moves
.
urllib
.
request
.
HTTPSHandler
(
context
=
ssl
.
_create_unverified_context
())
]
handlers
.
extend
(
HttpAuthenticated
.
u2handlers
(
self
))
return
handlers
...
...
bt5/erp5_paypal_secure_payment/DocumentTemplateItem/portal_components/document.erp5.PaypalService.py
View file @
e4d074fc
...
...
@@ -27,8 +27,8 @@
#
##############################################################################
import
zope
from
urllib
import
urlencode
from
urllib2
import
urlopen
,
Request
from
six.moves.urllib.parse
import
urlencode
from
six.moves.urllib.request
import
urlopen
,
Request
from
zLOG
import
LOG
,
DEBUG
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
...
...
bt5/erp5_rss_reader/ExtensionTemplateItem/ERP5RSSFeed.py
0 → 100644
View file @
e4d074fc
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2006-2007 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
DateTime
import
DateTime
from
six.moves.urllib.request
import
urlopen
from
lxml
import
etree
import
re
from
zLOG
import
LOG
def
getObjectStringList
(
xml_string
,
element_to_find
=
'object'
):
"""
this function splits an ERP5 XML string into object
string list, each object string is converted
into utf-8 encoding and html entities are
translated into corresponding unicode code
"""
rss_doc
=
etree
.
fromstring
(
xml_string
)
return
[
etree
.
tostring
(
node
)
for
node
in
rss_doc
.
xpath
(
'//%s'
%
element_to_find
)]
def
setTextContent
(
self
):
"""
Edit text_content
"""
try
:
text_content
=
urlopen
(
self
.
asURL
()).
read
()
try
:
text_content
=
unicode
(
text_content
,
"utf-8"
).
encode
(
"utf-8"
)
except
UnicodeDecodeError
:
text_content
=
unicode
(
text_content
,
"iso-8859-1"
).
encode
(
"utf-8"
)
except
IOError
:
text_content
=
None
if
text_content
is
not
None
:
self
.
edit
(
text_content
=
text_content
)
def
setRSSItemProperties
(
self
,
rss_item
):
pass
\ No newline at end of file
bt5/erp5_run_my_doc/ExtensionTemplateItem/portal_components/extension.erp5.ERP5RunMyDocs.py
View file @
e4d074fc
...
...
@@ -57,8 +57,8 @@ def parseTestReport(text):
Return the content of a web page
"""
def
urlread
(
url
):
import
urllib
return
url
lib
.
url
open
(
url
).
read
()
from
six.moves.urllib.request
import
urlopen
return
urlopen
(
url
).
read
()
"""
Remove everything but the test in a webpage
...
...
bt5/erp5_short_message/DocumentTemplateItem/portal_components/document.erp5.EssendexGateway.py
View file @
e4d074fc
...
...
@@ -29,7 +29,8 @@
"""Receive or send SMS"""
#Import python module
import
urllib
from
six.moves.urllib.parse
import
urlencode
,
unquote
from
six.moves.urllib.request
import
urlopen
from
lxml
import
etree
from
DateTime
import
DateTime
...
...
@@ -91,14 +92,14 @@ class EssendexGateway(XMLObject):
if
len
(
parts
)
==
1
:
data
=
parts
[
0
].
split
(
'='
)
#Remove \n et \r from value
result
[
data
[
0
]]
=
u
rllib
.
u
nquote
(
data
[
1
].
replace
(
'
\
r
'
,
''
).
replace
(
'
\
n
'
,
''
))
result
[
data
[
0
]]
=
unquote
(
data
[
1
].
replace
(
'
\
r
'
,
''
).
replace
(
'
\
n
'
,
''
))
else
:
#Mutil values
subresult
=
{}
for
part
in
parts
:
data
=
part
.
split
(
'='
)
subresult
[
data
[
0
]]
=
u
rllib
.
u
nquote
(
data
[
1
].
replace
(
'
\
r
'
,
''
).
replace
(
'
\
n
'
,
''
))
subresult
[
data
[
0
]]
=
unquote
(
data
[
1
].
replace
(
'
\
r
'
,
''
).
replace
(
'
\
n
'
,
''
))
result
[
index
]
=
subresult
#Increment index for next
index
+=
1
...
...
@@ -161,8 +162,8 @@ class EssendexGateway(XMLObject):
params
[
'Test'
]
=
1
LOG
(
"EssendexGateway"
,
INFO
,
params
)
params
=
url
lib
.
url
encode
(
params
)
page
=
url
lib
.
url
open
(
base_url
,
params
)
params
=
urlencode
(
params
)
page
=
urlopen
(
base_url
,
params
)
result
=
self
.
_fetchPageAsDict
(
page
)
if
result
[
'Result'
]
==
"OK"
:
message_ids
=
result
.
get
(
'MessageIDs'
,
""
)
...
...
@@ -171,7 +172,7 @@ class EssendexGateway(XMLObject):
return
message_ids
.
split
(
","
)
elif
result
[
'Result'
]
==
"Error"
:
#we get an error when call the gateway
raise
SMSGatewayError
(
u
rllib
.
u
nquote
(
result
.
get
(
'Message'
,
"Impossible to send the SMS"
)))
raise
SMSGatewayError
(
unquote
(
result
.
get
(
'Message'
,
"Impossible to send the SMS"
)))
elif
result
[
'Result'
]
==
"Test"
:
#just a test, no message id
return
None
...
...
@@ -190,15 +191,15 @@ class EssendexGateway(XMLObject):
'MessageID'
:
message_id
,
}
params
=
url
lib
.
url
encode
(
params
)
page
=
url
lib
.
url
open
(
base_url
,
params
)
params
=
urlencode
(
params
)
page
=
urlopen
(
base_url
,
params
)
result
=
self
.
_fetchPageAsDict
(
page
)
if
result
[
'Result'
]
==
"OK"
:
return
result
.
get
(
'MessageStatus'
).
lower
()
elif
result
[
'Result'
]
==
"Error"
:
#we get an error when call the gateway
raise
SMSGatewayError
(
u
rllib
.
u
nquote
(
result
.
get
(
'Message'
,
"Impossible to get the message status"
)))
raise
SMSGatewayError
(
unquote
(
result
.
get
(
'Message'
,
"Impossible to get the message status"
)))
security
.
declarePublic
(
'receive'
)
def
receive
(
self
,
REQUEST
,
**
kw
):
...
...
@@ -319,8 +320,8 @@ class EssendexGateway(XMLObject):
params
[
'Test'
]
=
1
LOG
(
"EssendexGateway"
,
INFO
,
params
)
params
=
url
lib
.
url
encode
(
params
)
page
=
url
lib
.
url
open
(
base_url
,
params
)
params
=
urlencode
(
params
)
page
=
urlopen
(
base_url
,
params
)
result
=
self
.
_fetchPageAsDict
(
page
)
if
result
[
'Result'
]
==
"OK"
:
...
...
@@ -344,6 +345,6 @@ class EssendexGateway(XMLObject):
LOG
(
"EssendexGateway"
,
INFO
,
result
)
elif
result
[
'Result'
]
==
"Error"
:
#we get an error when call the gateway
raise
SMSGatewayError
(
u
rllib
.
u
nquote
(
result
.
get
(
'Message'
,
"Impossible to get last message list"
)))
raise
SMSGatewayError
(
unquote
(
result
.
get
(
'Message'
,
"Impossible to get last message list"
)))
bt5/erp5_short_message/DocumentTemplateItem/portal_components/document.erp5.MobytGateway.py
View file @
e4d074fc
...
...
@@ -29,7 +29,8 @@
"""Receive or send SMS"""
#Import python module
import
urllib
from
six.moves.urllib.parse
import
urlencode
,
unquote
from
six.moves.urllib.request
import
urlopen
from
DateTime
import
DateTime
#Import Zope module
...
...
@@ -179,8 +180,8 @@ class MobytGateway(XMLObject):
LOG
(
"MobytGateway"
,
INFO
,
params
)
result
=
{
'status'
:
"Test"
}
else
:
params
=
url
lib
.
url
encode
(
params
)
page
=
url
lib
.
url
open
(
base_url
,
params
)
params
=
urlencode
(
params
)
page
=
urlopen
(
base_url
,
params
)
result
=
self
.
_fetchSendResponseAsDict
(
page
)
#Check result and return
...
...
@@ -188,7 +189,7 @@ class MobytGateway(XMLObject):
return
[
result
.
get
(
'status_info'
,
""
)]
#return message id (gateway side)
elif
result
[
'status'
]
==
"KO"
:
#we get an error when call the gateway
raise
SMSGatewayError
(
u
rllib
.
u
nquote
(
result
.
get
(
'status_info'
,
"Impossible to send the SMS"
)))
raise
SMSGatewayError
(
unquote
(
result
.
get
(
'status_info'
,
"Impossible to send the SMS"
)))
elif
result
[
'status'
]
==
"Test"
:
#just a test, no message id
return
None
...
...
@@ -206,8 +207,8 @@ class MobytGateway(XMLObject):
"type"
:
'notify'
,
"schema"
:
1
}
params
=
url
lib
.
url
encode
(
params
)
page
=
url
lib
.
url
open
(
base_url
,
params
)
params
=
urlencode
(
params
)
page
=
urlopen
(
base_url
,
params
)
result
=
self
.
_fetchStatusResponseAsDict
(
page
)
if
result
[
'status'
]
==
"OK"
:
...
...
@@ -223,7 +224,7 @@ class MobytGateway(XMLObject):
elif
result
[
'status'
]
==
"KO"
:
#we get an error when call the gateway
raise
SMSGatewayError
(
u
rllib
.
u
nquote
(
result
.
get
(
'status_info'
,
"Impossible to get the message status"
)))
raise
SMSGatewayError
(
unquote
(
result
.
get
(
'status_info'
,
"Impossible to get the message status"
)))
security
.
declarePublic
(
'receive'
)
def
receive
(
self
,
REQUEST
):
...
...
bt5/erp5_sso_openam/ExtensionTemplateItem/portal_components/extension.erp5.OpenAMLogout.py
View file @
e4d074fc
...
...
@@ -25,8 +25,8 @@
#
##############################################################################
from
urllib
import
urlencode
from
urllib2
import
urlopen
from
six.moves.urllib.parse
import
urlencode
from
six.moves.urllib.request
import
urlopen
def
OpenAMLogout
(
self
,
url
,
token
):
code
=
urlopen
(
url
,
urlencode
({
'subjectid'
:
token
})).
getcode
()
...
...
bt5/erp5_test_result/DocumentTemplateItem/portal_components/document.erp5.GitlabRESTConnector.py
View file @
e4d074fc
...
...
@@ -27,7 +27,7 @@
##############################################################################
from
urllib
import
quote_plus
from
six.moves.urllib.parse
import
quote_plus
from
six.moves.urllib.parse
import
urlparse
from
six.moves.urllib.parse
import
urljoin
import
logging
...
...
bt5/erp5_ui_test_core/ExtensionTemplateItem/portal_components/extension.erp5.ERP5Zuite.py
View file @
e4d074fc
...
...
@@ -38,9 +38,9 @@ def UpdateImage(image):
image
.
_update_image_info
()
def
urlread
(
url
,
safe_return
=
0
):
import
urllib
from
six.moves.urllib.request
import
urlopen
try
:
return
url
lib
.
url
open
(
url
).
read
()
return
urlopen
(
url
).
read
()
except
IOError
as
e
:
if
safe_return
:
# Return an Selenium test code that will obviously fail. This
...
...
bt5/erp5_web/DocumentTemplateItem/portal_components/document.erp5.StaticWebSection.py
View file @
e4d074fc
...
...
@@ -37,7 +37,7 @@ from Products.ERP5Type import Permissions
from
webdav.NullResource
import
NullResource
import
urllib
from
six.moves.urllib.parse
import
unquote
MARKER
=
[]
...
...
@@ -69,7 +69,7 @@ class StaticWebSection(WebSection):
# Drop the automatically added VirtualHostMonster object ID
virtual_url_part_tuple
=
request
.
get
(
'VIRTUAL_URL_PARTS'
,
None
)
if
(
virtual_url_part_tuple
is
not
None
)
and
\
(
not
u
rllib
.
u
nquote
(
virtual_url_part_tuple
[
-
1
]).
endswith
(
"/"
.
join
(
url_list
))):
(
not
unquote
(
virtual_url_part_tuple
[
-
1
]).
endswith
(
"/"
.
join
(
url_list
))):
url_list
.
pop
(
0
)
if
request
.
get
(
'ACTUAL_URL'
,
''
).
endswith
(
"/"
):
# or len(url_list) == 0:
...
...
bt5/erp5_wechat_secure_payment/DocumentTemplateItem/portal_components/document.erp5.WechatService.py
View file @
e4d074fc
...
...
@@ -3,7 +3,8 @@ from AccessControl import ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
from
zLOG
import
LOG
,
WARNING
import
random
,
string
,
hashlib
,
urllib2
,
socket
import
random
,
string
,
hashlib
,
socket
from
six.moves.urllib.request
import
Request
,
urlopen
from
six.moves.urllib.parse
import
urlparse
from
six
import
string_types
as
basestring
try
:
...
...
@@ -103,8 +104,8 @@ class WechatService(XMLObject):
params
[
'sign'
]
=
self
.
calculateSign
(
params
,
self
.
getServiceApiKey
())
LOG
(
'WechatService'
,
WARNING
,
"getSandboxKey : data = %s SANDBOX_KEY_URL = %s"
%
(
self
.
convert_dict_to_xml
(
params
),
SANDBOX_KEY_URL
),
error
=
False
)
result
=
urllib2
.
Request
(
SANDBOX_KEY_URL
,
data
=
self
.
convert_dict_to_xml
(
params
))
result_data
=
url
lib2
.
url
open
(
result
)
result
=
Request
(
SANDBOX_KEY_URL
,
data
=
self
.
convert_dict_to_xml
(
params
))
result_data
=
urlopen
(
result
)
result_read
=
result_data
.
read
()
result_dict_content
=
self
.
convert_xml_to_dict
(
result_read
)
return_code
=
result_dict_content
.
get
(
'return_code'
,
''
)
...
...
@@ -151,8 +152,8 @@ class WechatService(XMLObject):
LOG
(
'callWechatApi'
,
WARNING
,
"data = %s URL = %s"
%
(
self
.
convert_dict_to_xml
(
wechat_dict
),
wechat_url
+
URL
),
error
=
False
)
# send data
result
=
urllib2
.
Request
(
wechat_url
+
URL
,
data
=
self
.
convert_dict_to_xml
(
wechat_dict
))
result_data
=
url
lib2
.
url
open
(
result
)
result
=
Request
(
wechat_url
+
URL
,
data
=
self
.
convert_dict_to_xml
(
wechat_dict
))
result_data
=
urlopen
(
result
)
result_read
=
result_data
.
read
()
result_dict_content
=
self
.
convert_xml_to_dict
(
result_read
)
return_code
=
result_dict_content
[
'return_code'
]
...
...
product/ERP5/tests/erp5_url_checker.py
View file @
e4d074fc
...
...
@@ -15,13 +15,13 @@
from
threading
import
Thread
from
time
import
sleep
from
urllib
import
addinfourl
from
urllib
import
splithost
from
urllib
import
splituser
from
urllib
import
unquote
from
urllib
import
splittype
from
six.moves.urllib.parse
import
splithost
from
six.moves.urllib.parse
import
splituser
from
six.moves.urllib.parse
import
unquote
from
six.moves.urllib.parse
import
splittype
import
string
from
urllib
import
FancyURLopener
from
six.moves.urllib.request
import
FancyURLopener
from
six.moves.http_cookies
import
SimpleCookie
def
main
():
...
...
product/ERP5/tests/testInvalidationBug.py
View file @
e4d074fc
...
...
@@ -30,7 +30,7 @@
import
threading
import
unittest
import
urllib
from
six.moves.urllib.request
import
urlopen
import
transaction
import
pkg_resources
from
DateTime
import
DateTime
...
...
@@ -161,7 +161,7 @@ class TestInvalidationBug(ERP5TypeTestCase):
storage
.
_server
=
None
# ... monkey-patch done
## create object
url
lib
.
url
open
(
new_content_url
).
read
()
urlopen
(
new_content_url
).
read
()
## validate reindex activity
activity_tool
.
distribute
()
self
.
assertEqual
(
1
,
len
(
activity_tool
.
getMessageList
()))
...
...
product/ERP5/tests/utils.py
View file @
e4d074fc
...
...
@@ -29,7 +29,7 @@ import os
import
tarfile
import
xml.parsers.expat
import
xml.dom.minidom
from
urllib
import
url2pathname
from
six.moves.urllib.request
import
url2pathname
from
ZODB.DemoStorage
import
DemoStorage
from
ZODB
import
DB
from
Products.ERP5Type.XMLExportImport
import
importXML
...
...
product/ERP5Type/patches/urllib_opener.py
View file @
e4d074fc
...
...
@@ -36,7 +36,7 @@ import os
import
dircache
import
mimetypes
,
mimetools
from
email.utils
import
formatdate
class
DirectoryFileHandler
(
urllib2
.
FileHandler
):
class
DirectoryFileHandler
(
six
.
moves
.
urllib
.
request
.
FileHandler
):
"""
Extends the file handler to provide an HTML
representation of local directories.
...
...
@@ -55,7 +55,7 @@ class DirectoryFileHandler(urllib2.FileHandler):
def
open_local_file
(
self
,
req
):
host
=
req
.
get_host
()
file
=
req
.
get_selector
()
localfile
=
urllib2
.
url2pathname
(
file
)
localfile
=
six
.
moves
.
urllib
.
request
.
url2pathname
(
file
)
stats
=
os
.
stat
(
localfile
)
size
=
stats
.
st_size
modified
=
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
...
...
@@ -64,7 +64,7 @@ class DirectoryFileHandler(urllib2.FileHandler):
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
if
host
:
host
,
port
=
urllib
.
splitport
(
host
)
host
,
port
=
six
.
moves
.
urllib
.
parse
.
splitport
(
host
)
if
not
host
or
\
(
not
port
and
socket
.
gethostbyname
(
host
)
in
self
.
get_names
()):
try
:
...
...
@@ -73,16 +73,16 @@ class DirectoryFileHandler(urllib2.FileHandler):
s
.
write
(
'<html><head><base href="%s"/></head><body>'
%
(
'file:'
+
file
))
s
.
write
(
'<p>Directory Content:</p>'
)
for
f
in
file_list
:
s
.
write
(
'<p><a href="%s">%s</a></p>
\
n
'
%
(
urllib
.
quote
(
f
),
f
))
s
.
write
(
'<p><a href="%s">%s</a></p>
\
n
'
%
(
six
.
moves
.
urllib
.
parse
.
quote
(
f
),
f
))
s
.
write
(
'</body></html>'
)
s
.
seek
(
0
)
headers
=
mimetools
.
Message
(
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
'text/html'
,
size
,
modified
)))
return
urllib2
.
addinfourl
(
s
,
headers
,
'file:'
+
file
)
return
six
.
moves
.
urllib
.
response
.
addinfourl
(
s
,
headers
,
'file:'
+
file
)
except
OSError
:
return
urllib2
.
addinfourl
(
open
(
localfile
,
'rb'
),
return
six
.
moves
.
urllib
.
response
.
addinfourl
(
open
(
localfile
,
'rb'
),
headers
,
'file:'
+
file
)
raise
urllib2
.
URLError
(
'file not on local host'
)
opener
=
urllib2
.
build_opener
(
DirectoryFileHandler
)
urllib2
.
install_opener
(
opener
)
raise
six
.
moves
.
urllib
.
error
.
URLError
(
'file not on local host'
)
opener
=
six
.
moves
.
urllib
.
request
.
build_opener
(
DirectoryFileHandler
)
six
.
moves
.
urllib
.
request
.
install_opener
(
opener
)
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
e4d074fc
...
...
@@ -18,7 +18,6 @@ import string
import
sys
import
time
import
traceback
import
urllib
from
six.moves
import
configparser
from
contextlib
import
contextmanager
from
io
import
BytesIO
...
...
product/ERP5Type/tests/testUpgradeInstanceWithOldDataFs.py
View file @
e4d074fc
...
...
@@ -29,7 +29,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from
Products.ERP5Type
import
WITH_LEGACY_WORKFLOW
from
six.moves
import
cStringIO
as
StringIO
import
unittest
import
urllib
from
six.moves.urllib.parse
import
urlencode
import
six.moves.http_client
...
...
@@ -120,7 +120,7 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
ret
=
self
.
publish
(
'%s/portal_alarms/promise_check_upgrade'
%
self
.
portal
.
getPath
(),
basic
=
'%s:current'
%
self
.
id
(),
stdin
=
StringIO
(
url
lib
.
url
encode
({
stdin
=
StringIO
(
urlencode
({
'Base_callDialogMethod:method'
:
''
,
'dialog_id'
:
'Alarm_viewSolveDialog'
,
'dialog_method'
:
'Alarm_solve'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment